2014-10-29 3 views
0

Нажмите на изображение, замените его на relativelayout, как показано ниже. Этот нижний раздел должен быть ниже списка. Проблема в том, что я не вижу список в предварительном просмотре моей IDE.как выровнять вид сверху 1 из 2 просмотров

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin"> 

<LinearLayout 
    android:id="@+id/bottomSection" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="bottom" 
    android:orientation="vertical"> 

    <ImageView 
     android:id="@+id/icon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end" 
     android:onClick="switch" 
     android:src="@drawable/ic_edit" 
     android:visibility="visible" /> 

    <RelativeLayout 
     android:id="@+id/rl" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="gone"> 

    </RelativeLayout> 
</LinearLayout> 

<ListView 
    android:id="@+id/lv" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@id/bottomSection" /> 
</RelativeLayout> 
+1

доля макет XML и то, что вы пробовали варианты –

+0

Возьмите FrameLayout в сноске и списка следует динамически добавлять макет в соответствии с вашими потребностями –

ответ

0

Попробуйте этот путь, надейтесь, что это поможет вам решить вашу проблему.

У вас есть xml vertical LinearLayout как родительский макет и A, по щелчку как в активности, например, когда A show и click show B и скрыть A и наоборот.

<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:id="@+id/linearLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="visible"> 

     </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="gone"> 

    </LinearLayout> 
    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 
</LinearLayout> 
1

Вы можете поместить два linearlayouts в другом LinearLayout, и использовать родительский LinearLayout для справки в Listview.

Как это:

<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" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.tempproj.MainActivity" > 

    <LinearLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:id="@+id/lay1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:visibility="visible" > 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/lay2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:visibility="gone" > 
     </LinearLayout> 
    </LinearLayout> 

    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/container" /> 

</RelativeLayout> 

Таким образом, ваш ListView будет на вершине контейнера LinearLayout, независимо от того, LinearLayout видна внутри этого. Надеюсь, поможет.

Смежные вопросы