2016-06-28 28 views
-2

我的意思是,我想在html中制作一个元素。你知道,没有什么不对,它有自己的分工。但是在我所有的活动中,看起来都像是在一个地方。我怎样才能做到这一点?使元素变得牢固?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity"> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:orientation="vertical"> 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar"/> 

    </LinearLayout> 

    <FrameLayout 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <com.blunderer.materialdesignlibrary.views.CardView 
      android:id="@+id/cardview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:mdl_title="CardView" 
      app:mdl_description="A Basic CardView" 
      app:mdl_normalButton="Normal" 
      app:mdl_highlightButton="Highlight" 
      app:mdl_imagePosition="none" 
      android:layout_margin="20dp" 
      android:layout_marginTop="10dp" 
      android:layout_marginBottom="0dp"/> 


     <com.blunderer.materialdesignlibrary.views.CardView 
      android:id="@+id/cardview2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:mdl_title="127.0.0.1:8080" 
      app:mdl_description="Konum: Yerel\nPing: 0 ms" 
      app:mdl_imagePosition="none" 
      android:layout_margin="20dp" 
      android:layout_marginTop="10dp" 
      android:layout_marginBottom="0dp"/> 

    </FrameLayout> 

</RelativeLayout> 

这是我的xml。

+0

分享你的xml文件 –

回答

0

问题是您正在使用相对布局作为父级布局,并且您未分配子级相对于彼此的位置。

你能做什么: -

选项1

更换相对布局与垂直定向的线性布局,根布局,你会意识到现在所有的意见都对准一个下面的另一个。你的观点看起来像一个网页“坚实”。 它会让你感觉就像你在家里一样,因为我认为你是web开发者,而android是新手。

http://www.tutorialspoint.com/android/android_linear_layout.htm

选项2

正确的方法是分配视图位置相对于彼此。你需要把下面或彼此旁边的看法: -

http://androidexample.com/Relative_Layout_Basics_-_Android_Example/index.php?view=article_discription&aid=73&aaid=97

选项3

尝试拖放在IDE的XML观众观看。这将会工作fir演示,但不推荐用于真实项目。