下面给出了一个代码块,它在我的布局上重复了五次
<RelativeLayout android:layout_alignParentLeft="true"
android:layout_below="@+id/button_clock_homescreen"
android:layout_width="fill_parent" android:id="@+id/rel1"
android:layout_marginTop="40dp" android:layout_height="70dp">
<ImageView android:id="@+id/image_sound_selected"
android:visibility="visible" android:layout_marginLeft="10dp"
android:src="@drawable/airpurifier_cat" android:layout_width="60dp"
android:layout_height="60dp"></ImageView>
<LinearLayout android:orientation="vertical"
android:layout_height="fill_parent" android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/image_sound_selected"
android:layout_marginLeft="10dp" android:layout_width="fill_parent">
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button android:background="@drawable/soundselect"
android:layout_width="180dp" android:layout_height="40dp"
android:textColor="#FFF" android:text="Select Sound" android:id="@+id/button_soundselect1"></Button>
<Button android:layout_width="40dp" android:background="@drawable/ipod_play"
android:id="@+id/button_player1_play" android:layout_height="30dp"></Button>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/pitch_balance"
android:id="@+id/imagebutton_home_player1_setting">
</ImageButton>
<SeekBar android:indeterminateDrawable="@drawable/volumebutton"
android:id="@+id/seekbar_player1" android:soundEffectsEnabled="true"
android:layout_height="wrap_content" android:layout_gravity="center_vertical"
android:layout_width="140dp"></SeekBar>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/linearLayout2" android:layout_width="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/linearlayout_home_mediaplayer1_setting"
android:visibility="invisible" android:layout_height="40dp">
<Button android:layout_width="40dp"
android:layout_marginLeft="20dp" android:layout_height="20dp"
android:background="@drawable/ipod_pause" android:id="@+id/button_player1_setting_playpause"></Button>
<Button android:layout_width="50dp" android:background="@drawable/ipod_fforward"
android:layout_marginLeft="20dp" android:layout_height="20dp"
android:id="@+id/button_player1_setting_forward"></Button>
<Button android:layout_width="50dp"
android:layout_marginLeft="20dp" android:background="@drawable/ipod_bback"
android:id="@+id/button_player1_setting_reverse"
android:layout_height="20dp"></Button>
<Button android:background="@drawable/ipod_loop_off"
android:layout_width="50dp" android:layout_marginLeft="20dp"
android:id="@+id/button_player1_setting_loopplay"
android:layout_height="20dp"></Button>
</LinearLayout>
</LinearLayout>
我已经以这种方式在这个块上应用了scrollview,我将这五个重复的块以线性布局包含在内并放入一个宽度为&amp;的滚动视图中。高度:FILL_PARENT
这是结果代码
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent" android:layout_height="620px" android:fillViewport="true"
android:measureAllChildren="true" android:scrollbars="vertical">
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="fill_parent">
<!-- PLAYER ONE START -->
<RelativeLayout android:layout_alignParentLeft="true"
android:layout_below="@+id/button_clock_homescreen"
android:layout_width="fill_parent" android:id="@+id/rel1"
android:layout_marginTop="40dp" android:layout_height="70dp">
<ImageView android:id="@+id/image_sound_selected"
android:visibility="visible" android:layout_marginLeft="10dp"
android:src="@drawable/airpurifier_cat" android:layout_width="60dp"
android:layout_height="60dp"></ImageView>
<LinearLayout android:orientation="vertical"
android:layout_height="fill_parent" android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/image_sound_selected"
android:layout_marginLeft="10dp" android:layout_width="fill_parent">
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<Button android:background="@drawable/soundselect"
android:layout_width="180dp" android:layout_height="40dp"
android:textColor="#FFF" android:text="Select Sound" android:id="@+id/button_soundselect1"></Button>
<Button android:layout_width="40dp" android:background="@drawable/ipod_play"
android:id="@+id/button_player1_play" android:layout_height="30dp"></Button>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<ImageButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/pitch_balance"
android:id="@+id/imagebutton_home_player1_setting">
</ImageButton>
<SeekBar android:indeterminateDrawable="@drawable/volumebutton"
android:id="@+id/seekbar_player1" android:soundEffectsEnabled="true"
android:layout_height="wrap_content" android:layout_gravity="center_vertical"
android:layout_width="140dp"></SeekBar>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/linearLayout2" android:layout_width="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/linearlayout_home_mediaplayer1_setting"
android:visibility="invisible" android:layout_height="40dp">
<Button android:layout_width="40dp"
android:layout_marginLeft="20dp" android:layout_height="20dp"
android:background="@drawable/ipod_pause" android:id="@+id/button_player1_setting_playpause"></Button>
<Button android:layout_width="50dp" android:background="@drawable/ipod_fforward"
android:layout_marginLeft="20dp" android:layout_height="20dp"
android:id="@+id/button_player1_setting_forward"></Button>
<Button android:layout_width="50dp"
android:layout_marginLeft="20dp" android:background="@drawable/ipod_bback"
android:id="@+id/button_player1_setting_reverse"
android:layout_height="20dp"></Button>
<Button android:background="@drawable/ipod_loop_off"
android:layout_width="50dp" android:layout_marginLeft="20dp"
android:id="@+id/button_player1_setting_loopplay"
android:layout_height="20dp"></Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
我很困惑什么是问题而且scrollview不可见......
答案 0 :(得分:2)
尝试将此标记添加到ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"