如何在android中创建数字/索引滚动条

时间:2014-11-26 14:47:35

标签: android

我的目的是获得这样的东西:

enter image description here

我希望能够创建一个类似的侧边菜单,您可以在其中滑动指定的特定数字。然后,显示的内容将根据选择的数字而改变。

有没有人知道处理这个问题的好方法并创建一个好的侧边菜单

1 个答案:

答案 0 :(得分:0)

尝试我的示例布局进行滚动

    <?xml version="1.0" encoding="utf-8"?>
   <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:scrollbarStyle="insideInset"
   android:fadeScrollbars="true"
   android:scrollbarSize="10dip"
   android:fitsSystemWindows="true" >
   <LinearLayout
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:background="@drawable/tt"  >
   <TextView
   android:layout_width="fill_parent"
    android:layout_height="wrap_content"
   android:text="Text one.."
   android:textColor="#000000"
   android:background="#ffffff"
   android:textSize="20dip"/>
   <HorizontalScrollView
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:scrollbarStyle="insideInset"
   android:fadeScrollbars="true"
   android:scrollbarSize="10dip"
   android:fitsSystemWindows="true"   >
   <LinearLayout
   android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
   <ImageView
    android:src="@drawable/abc"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
      android:layout_gravity="center"/>
     <ImageView
     android:src="@drawable/fgj"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center"/>
    <ImageView
     android:src="@drawable/ggcgh"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
    android:layout_gravity="center"/>
    <ImageView
    android:src="@drawable/thhh"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" />
    <ImageView
   android:src="@drawable/fhg"
   android:layout_width="wrap_content"
    android:layout_height="wrap_content"
   android:layout_gravity="center" />
  <ImageView
   android:src="@drawable/jgeraej"
   android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" />
  <ImageView
  android:src="@drawable/jhdfdjh"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"/>
  </LinearLayout>
 </HorizontalScrollView>
  <TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:background="#ffffff"
  android:textColor="#000000"
  android:text="Text two.."
  android:textSize="20dip"/>
 <HorizontalScrollView
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:scrollbarStyle="insideInset"
   android:fadeScrollbars="true"
 android:scrollbarSize="10dip"
 android:fitsSystemWindows="true" >
 <LinearLayout
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="horizontal">
<ImageView
  android:src="@drawable/thhh"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"/>
  <ImageView
  android:src="@drawable/abc"
  android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"/>
 <ImageView
  android:src="@drawable/fgj"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
   android:layout_gravity="center"/>
   <ImageView
   android:src="@drawable/hghhgh"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center" />
   <ImageView
   android:src="@drawable/jgeraej"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"/>
   <ImageView
   android:src="@drawable/fhg"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center"/>
    <ImageView
    android:src="@drawable/thhh"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center"/>
     </LinearLayout>
     </HorizontalScrollView>
     </LinearLayout>
      </ScrollView>

See this Example