2014-10-29 3 views
1

레이아웃 디자인에 문제가 있습니다. Linearlayout에 GridView를 추가하려고하면 컨트롤이 보이지 않게됩니다 (GridView 아래에 있음).GridView는 RelativeLayout에서 동일한 레이아웃의 다른 컨트롤을 보이지 않게합니다.

내 필요한 설계는 다음과 같습니다

http://www.imagesup.net/pt-514145877008.png

내가 RelativeLayout의 그것을 만들려고하고 하나의 GridView를 사용했다. 여기 은 XML 레이아웃 파일입니다

purchase.xml 나는이 코드를 시도 할 때 가지고, 나는에의 GridView의 가시성을 설정하려고 할 때 또한 결과를 포함 무엇 여기

<?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="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="#FFFFFF"> 

    <LinearLayout 
     android:id="@+id/button_area" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:background="#FFFFFF" 
     android:orientation="vertical" 
     android:padding="10dp" > 


     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:text="One Year Subscription" 
      android:textColor="#000000" 
      android:textSize="18sp" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:paddingBottom="10dp" 
      android:paddingTop="15dp" 
      android:text="Rs. 500" 
      android:textColor="#000000" 
      android:textSize="18sp" /> 

     <Button 
      android:id="@+id/button_continue" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_gravity="right" 
      android:layout_marginBottom="5dp" 
      android:layout_marginTop="5dp" 
      android:background="#FF0000" 
      android:text="Buy" 
      android:textColor="#FFFFFF" > 

      <!-- continue button --> 
      <!-- select All check box --> 
     </Button> 
    </LinearLayout> 

     <View android:layout_width="match_parent" 
      android:layout_height="3dp" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp" 
      android:background="#CDCDCD"/> 

    <LinearLayout 
     android:id="@+id/monthly_subscription" 
     android:orientation="vertical" 
     android:layout_below="@+id/button_area" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:paddingBottom="10dp" 
      android:paddingTop="15dp" 
      android:text="monthly Subscription" 
      android:textColor="#000000" 
      android:textSize="18sp" />   
    <TextView 
     android:id="@+id/price_text" 
     android:layout_width="wrap_content" 
     android:layout_height="0dp" 
     android:layout_gravity="right" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" 
     android:gravity="right" 
     android:text="Rs 0" 
     android:textColor="#000000" 
     android:textSize="18sp" /> 

     <GridView 
     android:id="@+id/book_grid" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:numColumns="3" 
     android:padding="10dp" 
     tools:listitem="@layout/book_list_item" > 
    </GridView> 

    <Button 
      android:id="@+id/button_continue_bottom" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_gravity="right" 
      android:layout_margin="10dp" 
      android:layout_marginBottom="5dp" 
      android:layout_marginTop="10dp" 
      android:background="#FF0000" 
      android:text="Buy" 
      android:textColor="#FFFFFF" > 
     </Button> 

    </LinearLayout> 


</RelativeLayout> 

http://www.imagesup.net/pm-314145913100.png

내 디자인에 어떤 문제가 "사라"? 무엇이 컨트롤을 보이지 않게합니다.? 필요한 레이아웃으로 설치하도록 도와주세요.

답변

0

하단 레이아웃을 바깥쪽에 배치해야합니다. 다음 코드를 사용해보십시오.

<?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="fill_parent" 
android:layout_height="fill_parent" 
android:background="#FFFFFF> 

<!-- Align to parent top--> 
<LinearLayout 
    android:id="@+id/button_area" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:background="#FFFFFF" 
    android:gravity="center" 
    android:orientation="vertical" 
    android:padding="10dp"> 


    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:text="One Year Subscription" 
     android:textColor="#000000" 
     android:textSize="18sp" /> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:paddingBottom="10dp" 
     android:paddingTop="15dp" 
     android:text="Rs. 500" 
     android:textColor="#000000" 
     android:textSize="18sp" /> 

    <Button 
     android:id="@+id/button_continue" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_gravity="right" 
     android:layout_marginBottom="5dp" 
     android:layout_marginTop="5dp" 
     android:background="#FF0000" 
     android:text="Buy" 
     android:textColor="#FFFFFF"> 

     <!-- continue button --> 
     <!-- select All check box --> 
    </Button> 
</LinearLayout> 

<!-- layout below top linearlayout--> 
<View 
    android:id="@+id/line" 
    android:layout_width="match_parent" 
    android:layout_height="3dp" 
    android:layout_below="@+id/button_area" 
    android:layout_marginLeft="20dp" 
    android:layout_marginRight="20dp" 
    android:background="#CDCDCD" /> 

<!-- layout below line view but above bottom button--> 
<LinearLayout 
    android:id="@+id/monthly_subscription" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/button_continue_bottom" 
    android:layout_below="@+id/line" 
    android:orientation="vertical"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:paddingBottom="10dp" 
     android:paddingTop="15dp" 
     android:text="monthly Subscription" 
     android:textColor="#000000" 
     android:textSize="18sp" /> 

    <TextView 
     android:id="@+id/price_text" 
     android:layout_width="wrap_content" 
     android:layout_height="0dp" 
     android:layout_gravity="right" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" 
     android:gravity="right" 
     android:text="Rs 0" 
     android:textColor="#000000" 
     android:textSize="18sp" /> 

    <GridView 
     android:id="@+id/book_grid" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:numColumns="3" 
     android:padding="10dp" 
     android:stretchMode="columnWidth" 
     tools:listitem="@layout/book_list_item"></GridView> 


</LinearLayout> 

<!-- layout outside of linear layout and align to parent bottom--> 
<Button 
    android:id="@+id/button_continue_bottom" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_alignParentBottom="true" 
    android:layout_margin="10dp" 
    android:layout_marginBottom="5dp" 
    android:layout_marginTop="10dp" 
    android:background="#FF0000" 
    android:text="Buy" 
    android:textColor="#FFFFFF" /> 

</RelativeLayout> 
관련 문제