2014-09-06 2 views
1

Меня смущает дизайн макета Android. Я хочу, чтобы достичь макет в следующем изображении: enter image description hereAndroid LinearLayout: макет внутри макета

Но ниже код производит что-то вроде этого изображения: enter image description here

Мой код

<LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="50sp" 
     android:layout_below="@+id/view" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:background="@drawable/bg_shadow" 
     android:animateLayoutChanges="true" 
     android:layout_marginTop="5dp" 
     android:id="@+id/detailsLay"> 

     <CheckBox 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/repeat" 
      android:id="@+id/repeatCheckBox" 
      android:longClickable="false" 
      android:textColor="@android:color/background_light" 
      android:paddingTop="15sp" 
      android:paddingRight="15sp" 
      android:paddingLeft="1sp" 
      android:paddingBottom="15sp" /> 
     <TextView 
      android:layout_width="30dp" 
      android:layout_height="20sp" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:text="@string/sat" 
      android:id="@+id/satTextView" 
      android:layout_gravity="center_vertical|right" 
      android:textColor="@android:color/holo_orange_light" 
      android:layout_marginLeft="2sp" /> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/arrowDown" 
      android:src="@android:drawable/arrow_down_float" 
      android:layout_gravity="center_vertical" /> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/everyday"/> 
     </LinearLayout> 
    </LinearLayout> 
+0

Использовать 'relativeLayout' вместо – suitianshi

+0

Использовать' RelativeLayout' еще использовать разный макет для 'LinearLayour2' – SilentKiller

ответ

3

Это просто пример Xml учитесь на этом.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button" /> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Large Text" 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:src="@drawable/ic_launcher" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="CheckBox" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Large Text" 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 
    </LinearLayout> 

</LinearLayout> 

Используйте атрибуты, такие как вес и ориентация пользователя linearlayout.

+0

Bingo !!! Огромное спасибо. @Shabbir :) – rony36

+0

приветствуем счастливого кодирования. –