3

私はListViews自分のアプリにいくつかあり、すべての人にほぼ同じコードを書いていますが、いくつかはありScrollBar、すべてがandroid:scrollBars = "none"あり、機能しません。

それで、問題は何ですか?ScrollBars を非表示にするにはどうすればよいですか?

レイアウト ファイル:

 <com.zuanbank.android.widgets.RefreshListView 
  android:id="@+id/list_view"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/main_bg"
  android:orientation="vertical"
  android:scrollbars="none"
  app:init_footer="true"
  app:init_header="false">

</com.zuanbank.android.widgets.RefreshListView>

そして私のスタイル:

 <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">   </style>

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowAnimationStyle">@style/activityAnimation</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowBackground">@null</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorControlNormal">@color/blue_00a0ea</item>
    <item name="colorControlActivated">@color/colorControlActivated</item>
    <item name="colorSwitchThumbNormal">@color/blue_00a0ea</item>
</style>
4

1 に答える 1

1

xml が機能しない場合は、プログラムで非表示にしてみてください。

listview.setVerticalScrollBarEnabled(false); 
listview.setHorizontalScrollBarEnabled(false);

とにかく、xml の方法は機能しているはずです...ドキュメントに記載されているとおりです。

android:scrollbars="none"

編集:どうやら、デフォルトを使用していませんListView。1 つのオプションは、デフォルトの実装にロールバックし、SwipeRefreshLayout.

このような:

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/srl_refresh">
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/lv_data"
        android:choiceMode="singleChoice"
        android:scrollbars="none" />
</android.support.v4.widget.SwipeRefreshLayout>

次に、FragmentまたはActivityで、次の操作を行います。

srl_refresh = (SwipeRefreshLayout) rootView.findViewById(R.id.srl_refresh);
srl_refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
        doRefresh(); // Call your refresh method here.
    }
});
于 2015-08-13T02:41:06.090 に答える