【问题标题】:How to Rtl Horizontal ListView?如何 Rtl 水平 ListView?
【发布时间】:2015-10-28 09:16:27
【问题描述】:

我目前正在使用 Devsmartlib.jar 库。

这是我的 activitymain.xml 文件中的内容:

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="right">

<com.devsmart.android.ui.HorizontalListView
    android:id="@+id/hlistview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="right" />
</LinearLayout>

我想从右到左显示我的列表,但它不起作用。
请帮帮我。

【问题讨论】:

  • 你能发布一些代码来告诉我们你到目前为止所做的尝试吗?
  • @Arc676 编辑了我的帖子。
  • 请检查这个答案:link

标签: android android-layout listview android-listview right-to-left


【解决方案1】:

如果您尝试修改宽度以给圆圈留出空间,您可以在实际项目中执行此操作。如果您认为在每个项目中您的圆圈周围需要更多空间,请编辑各个项目的 XML 并将其添加到您拥有的圆圈的 ImageView

android:padding = "6dp"

或任何你认为看起来更好的尺寸,让那个圆圈不那么拥挤。

您的另一个主要选择是将其添加到您的实际ListView XML:

android:minWidth="50dp"

或任何看起来合适的值。这将为每个视图设置最小宽度。不过,我建议使用上面提到的视图的 XML,因为这是一个更通用的扩展解决方案。

您可以阅读有关android:minWidth in the Android docs here 的更多信息。

【讨论】:

    【解决方案2】:
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:gravity="right">
    
    <com.devsmart.android.ui.HorizontalListView
        android:id="@+id/hlistview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:stackFromBottom="true" //<==Add this
        android:layout_gravity="right" />
    </LinearLayout>
    

    【讨论】:

    • 我想从右到左显示 ListView。
    【解决方案3】:


    这段代码是工作!

    mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true);
    
    mRecyclerView.setLayoutManager(mLayoutManager);
    

    【讨论】:

    • 您应该提供有关答案作用的更多信息,而不仅仅是“此代码有效!” - 它将帮助提出问题的人理解解决方案,也有助于未来的用户
    猜你喜欢
    • 2013-04-08
    • 2019-03-14
    • 2023-03-25
    • 2010-09-26
    • 1970-01-01
    • 2015-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多