Kennt jemand eine Dokumentation zum android:scrollbarStyle? Ich würde gerne Beispiele für jeden der 4 Werte mit Screenshots sehen, wenn möglich. Ich sehe den Unterschied zwischen Außen- und Innentypen, aber worum geht es bei den Inset- und Outset-Teilen? Ich sehe zum Beispiel keinen Unterschied zwischen insideOutset und insideInset, ebenso sehe ich keinen Unterschied zwischen outsideOutset und outsideOutset.
vielen Dank im Voraus! Ben
Scott Stanchfield
Hier ist ein etwas ausführlicheres Beispiel. Ich habe Hintergrundfarben eingerichtet, um deutlicher zu machen, was hier vor sich geht.
Zuerst die Farben:
schwarz – Ränder
weiß – Polsterung
grau – der Inhalt der Bildlaufansicht
grün – die Bildlaufleiste wenn es nimmt seinen eigenen Platz ein (ich habe dies ausdrücklich als scrollbarTrackVertical
für die beiden “Einschub”-Beispiele)
Lassen Sie uns zwei Abschnitte definieren:
“Inhaltsbereich” – der Inhalt, der in der Bildlaufansicht angezeigt werden soll
“Padding” – der Abstand um den Inhalt der Scroll-Ansicht
Denken wir an die beiden Teile der scrollBarStyle
separat:
inside
– Die Bildlaufleiste erscheint Innerhalb den Inhaltsbereich (die Polsterung umschließt sowohl den Inhalt als auch die Bildlaufleiste)
outside
– Die Bildlaufleiste erscheint außen den Inhaltsbereich
overlay
– Die Bildlaufleiste überlagert den rechten Rand des Abschnitts, in dem sie sich befindet
inset
– Die Bildlaufleiste verschiebt den Abschnitt, in dem sie sich befindet, nach links und nimmt ihren eigenen Platz ein
Die Layout-XML wird unten angezeigt
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbarStyle="insideOverlay"
android:background="#fff"
android:fadeScrollbars="false"
android:layout_margin="8dp"
android:padding="16dp" >
<LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#aaa" >
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideOverlay"/>
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideOverlay"/>
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideOverlay"/>
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideOverlay"/>
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideOverlay"/>
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideOverlay"/>
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideOverlay"/>
</LinearLayout>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbarStyle="insideInset"
android:background="#fff"
android:scrollbarTrackVertical="@drawable/green_block"
android:fadeScrollbars="false"
android:layout_margin="8dp"
android:padding="16dp" >
<LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#aaa" >
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="insideInset" />
</LinearLayout>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbarStyle="outsideOverlay"
android:background="#fff"
android:fadeScrollbars="false"
android:layout_margin="8dp"
android:padding="16dp" >
<LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#aaa" >
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideOverlay" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideOverlay" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideOverlay" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideOverlay" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideOverlay" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideOverlay" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideOverlay" />
</LinearLayout>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#fff"
android:layout_weight="1"
android:scrollbarStyle="outsideInset"
android:scrollbarTrackVertical="@drawable/green_block"
android:fadeScrollbars="false"
android:layout_margin="8dp"
android:padding="16dp" >
<LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#aaa" >
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideInset" />
<TextView android:textSize="32sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="outsideInset" />
</LinearLayout>
</ScrollView>
</LinearLayout>
So legen Sie den Bildlaufleistenstil programmgesteuert fest:
setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY)
setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET)
setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY)
setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET)
Es gibt keine Werte wie outsideOutset und insideOutset. Mögliche vier Werte sind InsideOverlay, InsideInset, OutsideOverlay, OutsideInset
Die Dokumentation ist dort unter den folgenden zwei Links …
http://developer.android.com/reference/android/view/View.html#attr_android:scrollbarStyle
http://developer.android.com/reference/android/view/View.html#SCROLLBARS_INSIDE_INSET
Ich konnte die Dokumentation nicht richtig verstehen. Unter Bezugnahme auf die ApiDemos Scrollbar-Demo habe ich dies versucht. Aber ich habe festgestellt, dass es keinen Unterschied gibt insideInset und outsideOverlay .
Diese beiden Werte sind unterschiedlich, entweder sollte es beide als haben Einsatz oder Überlagerung
aktualisierte scrollbar3.xml ist
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/view1"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="insideOverlay"
android:background="@android:color/white"
android:overScrollMode="never">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@android:color/darker_gray"
android:text="@string/scroll_text" />
</ScrollView>
<ScrollView
android:id="@+id/view2"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="insideInset"
android:background="@android:color/white"
android:overScrollMode="never">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@android:color/darker_gray"
android:text="@string/scroll_text" />
</ScrollView>
<ScrollView
android:id="@+id/view3"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="outsideOverlay"
android:background="@android:color/white"
android:overScrollMode="never">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@android:color/darker_gray"
android:text="@string/scroll_text" />
</ScrollView>
<ScrollView
android:id="@+id/view4"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="outsideInset"
android:background="@android:color/white"
android:overScrollMode="never">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@android:color/darker_gray"
android:text="@string/scroll_text" />
</ScrollView></LinearLayout>
Ich hoffe jemand sieht das und klärt auf…
Die obigen Antworten haben bei mir nicht ganz funktioniert, also kam ich auf Folgendes:
Wenn Sie dies erreichen möchten, hier ist es:
Listenansicht:
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbVertical="@drawable/scrollbar" />
Bildlaufleiste ziehbar:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/transparent"
android:width="20dp"/>
<item
android:drawable="@android:color/holo_red_dark"
android:right="18dp" />
</layer-list>
Dank dieser Antwort
114325 0 0 cookie-check android ListView scrollbarStyle yes