2017-09-21 15 views
0

ツールバーを使用するにはテーマを設定する必要があるので(android:theme="@style/Theme.AppCompat.NoActionBar")、カスタムのスクロールサムが必要とするため、テーマを使用する必要があるかどうかはわかりません設定するテーマ。私の場合はandroid:theme="@style/GreenTheme"を使用しましたが、まだアクティビティ用のツールバーが必要です。これはどのように達成できますか?カスタムファーストスクロールをツールバーを含むアクティビティで使用する方法

Mainfestファイル(アクティビティ宣言)

<activity 
    android:name=".MainActivity" 
    android:label="@string/main_activity" 
    android:theme="@style/Theme.AppCompat.NoActionBar" /> 

のstyles.xml(高速スクロールの宣言)、高速スクロールと

<style name="GreenTheme" parent="AppTheme"> 
    <item name="android:fastScrollPreviewBackgroundRight">@drawable/fastscrollpreview_green</item> 
    <item name="android:fastScrollOverlayPosition">atThumb</item> 
    <item name="android:fastScrollThumbDrawable">@drawable/fastscrollthumb_green</item> 
    <item name="android:fastScrollTextColor">#FFF</item> 
</style> 

リストビュー

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <ListView 
     android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:choiceMode="singleChoice" 
     android:fastScrollEnabled="true" 
     android:scrollbarThumbVertical="@drawable/scrollbar_white" /> 

</LinearLayout> 

答えて

-1

ActivityMain.xml ツールバーを使用して、リストビューを使用して、リスト内のレイアウト(任意のレイアウト)を追加し、リスト内

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/holo_red_light" 
     android:minHeight="?attr/actionBarSize" 
     android:theme="?attr/actionBarTheme" /> 

     <ListView 
     android:id="@android:id/list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:choiceMode="singleChoice" 
     android:fastScrollEnabled="true" 
     android:scrollbarThumbVertical="@drawable/scrollbar_white" > 
      <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <Button 
        android:id="@+id/clxbtn" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentEnd="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 
        android:text="Close" /> 

    </LinearLayout> 
     </ListView> 

</LinearLayout > 
をより多くのビューを使用することができます
関連する問題