Я не могу показать LinearLayout внизу, чтобы прокрутить вид - PullRequest
2 голосов
/ 30 марта 2012

Я работаю с макетом, как показано ниже xml-кода

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

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/title" >
</RelativeLayout>

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="none">

    <RelativeLayout
        android:id="@+id/rel2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="250dp"
            android:layout_height="50dp"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp"
            android:background="@drawable/bkg_gold_btn"
            android:text="Button 1" />

        /*--------------------------------*/
        /* there are 12 more Buttons Here */
        /*--------------------------------*/
        <Button
            android:id="@+id/button10"
            android:layout_width="250dp"
            android:layout_height="50dp"
            android:layout_below="@+id/button9"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/bkg_gold_btn"
            android:text="Button 14" />
    </RelativeLayout>
</ScrollView>

  <LinearLayout
      android:id="@+id/add_layer"
      android:layout_width="fill_parent"
      android:layout_height="50dip"
      >
  </LinearLayout>

</LinearLayout>

Но когда я запускаю код, я не вижу LinearLayout в нижней части.пожалуйста, помогите мне.

Ответы [ 5 ]

4 голосов
/ 30 марта 2012
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical" >

<RelativeLayout
android:id="@+id/reltop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/title" >
</RelativeLayout>

<ScrollView
android:layout_below="@id/reltop"
android:layout_above="@id/add_layer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none">

<RelativeLayout
    android:id="@+id/rel2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/button1"
        android:layout_width="250dp"
        android:layout_height="50dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:background="@drawable/bkg_gold_btn"
        android:text="Button 1" />

    /*--------------------------------*/
    /* there are 12 more Buttons Here */
    /*--------------------------------*/
    <Button
        android:id="@+id/button10"
        android:layout_width="250dp"
        android:layout_height="50dp"
        android:layout_below="@+id/button9"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/bkg_gold_btn"
        android:text="Button 14" />
</RelativeLayout>
</ScrollView>

<LinearLayout
  android:id="@+id/add_layer"
  android:layout_width="fill_parent"
  android:layout_alignParentBottom="true"
  android:layout_height="50dip"
  >
</LinearLayout>

</RelativeLayout>
2 голосов
/ 30 марта 2012

Вы не можете видеть это Coz LinearLayout, Parent LinearLayout не Scrollable, и Scrollview покрывает весь экран, чтобы решить эту ситуацию, у вас есть два варианта, либо зафиксировать высоту ScrollView для некоторой фиксированной части экрана, используя вес,или пикселей.Или используйте RelativeLayout в качестве родителя для LinearLayout и Scrollview.Установите LinearLayout в нижней части родительского элемента и прокрутите представление LinearLayout.

1 голос
/ 30 марта 2012

Bottom LinearLayout не виден вам, возможно, из-за того, что ScrollView занимает оставшееся пространство экрана, чтобы показать, что n чисел кнопки в нем, потому что вы задали ему высоту wrap_content.

Выможно использовать weightSum attributr из LinearLayout, чтобы определить, какая часть экрана будет покрыта видом.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:weightSum="10"
android:background="@drawable/background" 
android:orientation="vertical" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_weight="1"
    android:layout_height="0dp" 
    android:background="@drawable/title" > 
</RelativeLayout> 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_weight="8"
    android:layout_height="0dp"
    android:scrollbars="none"> 

    <RelativeLayout 
        android:id="@+id/rel2" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" > 

    </RelativeLayout> 
</ScrollView> 

  <LinearLayout 
      android:id="@+id/add_layer" 
      android:layout_width="fill_parent" 
      android:layout_weight="1"
      android:layout_height="0dp"
      > 
  </LinearLayout> 

</LinearLayout> 
1 голос
/ 30 марта 2012

Добавьте android:gravity="bottom" android:layout_gravity="bottom" в LinearLayout и попробуйте добавить компоненты в LinearLayout.

или замените этот линейный макет на относительный макет, например:

 <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom" >

        <Button
           ... />
    </RelativeLayout>
0 голосов
/ 30 марта 2012

Вы можете переместить нижнюю LinearLayout в нижнюю часть RelativeLayout (id / rel2), тогда вы увидите ее

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...