2013-09-27 8 views
0

Я новичок в android. Я хочу, чтобы страница с ImageView была в верхней части экрана, 4 кнопки внизу страницы, и в середине страницы есть один frameLayout. Я сделал с xml-файлом для загрузки в FrameLayout. он содержит ScrollView и 10 кнопок. но когда я запускаю программу, последние две кнопки не отображаются на странице после прокрутки страницы.Не показывает две последние кнопки с ScrollView

Может ли кто-нибудь помочь мне?

main.xml:

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

    <ImageView 
     android:id="@+id/yellowbar" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/smallyelowbar" 
     android:adjustViewBounds="true" 
     android:scaleType="fitXY" 
     android:layout_alignParentTop="true"/> 
<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="0" 
    android:layout_gravity="bottom" 
    android:layout_below="@id/yellowbar"> 
     <FrameLayout 
      android:id="@+id/frameLayout" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1"/> 

</RelativeLayout> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_alignParentBottom="true"> 
     <ImageView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/topmenu" 
      android:adjustViewBounds="true" 
      android:scaleType="fitXY"/> 
       <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_alignParentBottom="true"> 

     <Button android:id="@+id/btn1" 
      android:layout_width="0dip" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:background="@drawable/more_selector"/> 
     <Button 
      android:id="@+id/btn2" 
      android:layout_width="0dip" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:background="@drawable/contact_selector"/> 
     <Button android:id="@+id/btn3" 
      android:layout_width="0dip" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:background="@drawable/product_selector"/> 
     <Button android:id="@+id/btn4" 
      android:layout_width="0dip" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:background="@drawable/introduce_selector"/> 
     </LinearLayout> 
     </LinearLayout> 
</RelativeLayout> 

scrooll.xml

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

<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<Button 
    android:id="@+id/btn1_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:text="@string/btn1_product" 
    android:textColor="@color/white" 
    android:textSize="10sp"/> 
<Button 
    android:id="@+id/btn2_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn2_product" 
    android:layout_below="@id/btn1_product" 
    android:textSize="10sp"/> 
<Button 
    android:id="@+id/btn3_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn3_product" 
    android:layout_below="@id/btn2_product" 
    android:textSize="10sp"/> 
<Button 
    android:id="@+id/btn4_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn4_product" 
    android:layout_below="@id/btn3_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn5_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn5_product" 
    android:layout_below="@id/btn4_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn6_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn6_product" 
    android:layout_below="@id/btn5_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn7_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn7_product" 
    android:layout_below="@id/btn6_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn8_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn8_product" 
    android:layout_below="@id/btn7_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn9_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn9_product" 
    android:layout_below="@id/btn8_product" 
    android:textSize="12sp"/> 
<Button 
    android:id="@+id/btn10_product" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="7dp" 
    android:background="@drawable/product_sub_selector" 
    android:textColor="@color/white" 
    android:text="@string/btn10_product" 
    android:layout_below="@id/btn9_product" 
    android:textSize="12sp"/> 

</RelativeLayout> 
</ScrollView> 

</LinearLayout> 

Спасибо за помощь.

+0

Я не уверен, но я думаю, что LinearLayout должен находиться внутри ScrollView. RelativeLayout в ScrollView не требуется. – Day

+0

«RelativeLayout» необходим, @Day. 'ScrollView' может содержать только один элемент. –

+0

Спасибо за быстрый ответ. Я удаляю LinearLayout, но не показывает две последние кнопки. Я думаю, если бы я изменил RelativeLaout на LinearLayout, не решите проблему. Я думаю, что две последние кнопки скрывают кнопки внизу страницы. – SensorS

ответ

0

Try давая "wrap_content" на высоте

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > </ScrollView> 
+0

Я изменил высоту ScrollView на wrap_content по программе, которая не была решена :(Как я могу решить эту проблему ?? Спасибо – SensorS

+0

Я думаю, проблема в LinearLayout в main.xml. Но я не знаю, как я могу изменить это до тех пор, пока проблема решена :( – SensorS

+0

Я вижу страницу предварительного просмотра main.xml, и я вижу, что FrameLayout находится ниже ImageView до тех пор, пока нижняя часть страницы и кнопки не будут включены в frameLayout. Я думаю, я должен установить FrameLayout в середине страницы между изображениями и кнопками. скажите мне, как я могу это реализовать? – SensorS

0

Добавить android:weightSum=4 в последнем LinearLayout первого XML.

+0

Я добавляю это к последнему LinearLayout, но проблема не решена :( – SensorS

+0

Преобразование Relativelayout в LinearLayout, это сработает. – Swetank

0

Конвертировать RelativeLayout в LinearLayout, он будет работать.

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