2015-03-01 3 views
0

Я пытаюсь сделать прокрутку из 15 кнопок в ней с фоном, но проблема в том, что фоновое изображение также будет прокручиваться с помощью кнопок. нужен ли фиксированный фон только с прокручиваемым содержимым? или по крайней мере я могу сделать петлю фона (симметричное изображение), чтобы никто не заметилПросмотр прокрутки с фиксированным фоном - Android

+0

Любой провал код, чтобы показать нам? – dgilperez

ответ

1

Похоже, вы установили фоновое изображение в ScrollView вместо родительского LinearLayout. Попробуйте что-то вроде:

<?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:background="@drawable/background" 
> 
    <ScrollView 
    ...> 
     <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/button_text" 
     android:drawableLeft="@drawable/button_icon" 
     ... /> 
    </ScrollView> 
</LinearLayout> 
+0

Это не работает. Он говорит, что просмотр прокрутки в относительной компоновке бесполезен – user3480296

+0

просто предупреждает об этом и пытается и запускается на мобильном телефоне – user3480296

0

<?xml version="1.0" encoding="utf-8"?> 
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:id="@+id/rel" 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="fill_parent" 
 
    > 
 

 
<ScrollView 
 
    android:id="@+id/scroll" 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="wrap_content" 
 
    android:background="@drawable/background" 
 
    android:fillViewport="true" 
 
    > 
 

 
    
 
    
 

 
<LinearLayout 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="wrap_content" 
 
    android:orientation="vertical" 
 
    > 
 

 
    <TextView 
 
     android:id="@+id/eee" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="@string/eee" 
 
     android:textSize="50sp" /> 
 

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

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

 
    <Button 
 
     android:id="@+id/button3" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
    <Button 
 
     android:id="@+id/button11" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
    <Button 
 
     android:id="@+id/button4" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
    <Button 
 
     android:id="@+id/button5" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
    <Button 
 
     android:id="@+id/button6" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
    <Button 
 
     android:id="@+id/button7" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
    <Button 
 
     android:id="@+id/button8" 
 
     style="?android:attr/buttonStyleSmall" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
    <Button 
 
     android:id="@+id/button9" 
 
     style="?android:attr/buttonStyleSmall" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
    <Button 
 
     android:id="@+id/button10" 
 
     style="?android:attr/buttonStyleSmall" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="Button" /> 
 

 
</LinearLayout></ScrollView> 
 

 

 

 
</RelativeLayout>

это работало для меня

+0

Ни одно из решений не сработало .. –

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