Java – no tabs for fragment display
•
Android
I need to create a scrollable tab at the top of the application. Tabhost looks ok, but I don't need fragment display (as shown in the figure). I just need a tab with clicklistener
I just need tabs like buttons, which need to be able to scroll and press horizontally. Any ideas on how or whether it can be done?
resolvent:
Below I provide a code snippet to change according to your requirements
<?xml version="1.0" encoding="utf-8"?>
<horizontalscrollview xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:src="@drawable/pic7"
android:text="image1" />
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Textview1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent">
<ImageButton
android:text="image2"
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:src="@drawable/pic2" />
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Textview2" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent">
<ImageButton
android:text="image3"
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:src="@drawable/pic7" />
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Textview3" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent">
<ImageButton
android:text="image4"
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:src="@drawable/pic5" />
<TextView
android:id="@+id/text4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Textview4" />
</LinearLayout>
</LinearLayout>
</horizontalscrollview>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码