2016-06-28 3 views
-2

私は、htmlのような要素を作りたいと思っています。あなたが知っている、何も間違っていないし、独自の部門があります。しかし、私の活動のすべてにおいて、すべてが1つの場所にあるように見えます。どうやってやるの?要素をソリッドにする?

<?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

は相対的なレイアウトを交換し、あなたはすべてのビューが今別の下に1整列している実現します。そして、あなたの意見はウェブページのように「強固」に見えます。 それはあなたが自宅のように感じるようになります。私はあなたがウェブデベロッパーで、New to 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のデモで動作しますが、実際のプロジェクトにはお勧めできません。

関連する問題