У меня есть горизонтальная прокрутка в моем приложении. По обе стороны от прокрутки я хочу сохранить кнопки со стрелками влево и вправо (ibLeft и ibRight ниже), которые должны быть видны все время и не должны скрываться за горизонтальными изображениями прокрутки в любой момент времени.
Проблемы, с которыми столкнулся я:
Каким-то образом горизонтальная прокрутка перекрывает две кнопки.
Кроме того, я не вижу ничего, что происходит, когда я устанавливаю прослушиватели onclick для кнопок. Я где-то читал, что это проблема, когда у нас горизонтальная прокрутка.
Пожалуйста, помогите.
<?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" >
<RelativeLayout
android:id="@+id/RelBt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="NEWS" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="LIVE T.V." />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="YOUTH" />
</RelativeLayout>
<TextView
android:id="@+id/tvtmp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Video will come up here" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/RelBt"
android:layout_below="@+id/tvtmp" >
<ImageButton
android:id="@+id/ibLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/ibRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
<HorizontalScrollView
android:id="@+id/hsv"
android:layout_width="wrap_content"
android:fadingEdgeLength="100dp"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView..../>
<ImageView..../>
<ImageView..../>
<ImageView..../>
<ImageView..../>
</RelativeLayout>
</HorizontalScrollView>
</RelativeLayout>
</RelativeLayout>
Java-файл
public class Main extends Activity implements OnClickListener{
HorizontalScrollView hSV;
ImageButton ibLeft,ibRight;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ibLeft=(ImageButton) findViewById(R.id.ibLeft);
ibLeft.setOnClickListener(this);
ibRight=(ImageButton) findViewById(R.id.ibRight);
ibRight.setOnClickListener(this);
hSV=(HorizontalScrollView) findViewById(R.id.hsv);
}
@Override
public void onClick(View v) {
if(v.getId()==R.id.ibLeft){
Toast.makeText(Main.this, "Left", Toast.LENGTH_SHORT).show();
}
else if(v.getId()==R.id.ibLeft){
Toast.makeText(Main.this, "Right", Toast.LENGTH_SHORT).show();
}
}
}