Android - 如何创建从右到左的水平列表视图?
Android - How to create Right-to-Left Horizontal-ListView?
在 Android 中是否有实用的方法(通常)创建从右到左的 Horizontal-ListView?
我已经搜索过并找到 this 但它似乎不太实用!
您应该尝试使用 RecyclerView。
是 post 解释如何将其用于水平列表视图。
编辑:
这是来自链接 post 的示例。
LinearLayoutManager layoutManager
= new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
RecyclerView myList = findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);
要使用RecyclerView,您应该导入相应的支持库。
com.android.support:recyclerview-v7:21.0.0
RecyclerView 帮助了我(而不是水平列表视图){thanX to @user2641570}。
public LinearLayoutManager (Context context, int orientation, boolean
reverseLayout)
Parameters context Current context, will be used to access resources.
orientation Layout orientation. Should be HORIZONTAL or VERTICAL.
reverseLayout When set to true, layouts from end to start.
所以我只声明 LinearLayoutManager 如下:
LinearLayoutManager layoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, true);
一切正常。
在 Android 中是否有实用的方法(通常)创建从右到左的 Horizontal-ListView?
我已经搜索过并找到 this 但它似乎不太实用!
您应该尝试使用 RecyclerView。
编辑:
这是来自链接 post 的示例。
LinearLayoutManager layoutManager
= new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
RecyclerView myList = findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);
要使用RecyclerView,您应该导入相应的支持库。
com.android.support:recyclerview-v7:21.0.0
RecyclerView 帮助了我(而不是水平列表视图){thanX to @user2641570}。
public LinearLayoutManager (Context context, int orientation, boolean reverseLayout)
Parameters context Current context, will be used to access resources.
orientation Layout orientation. Should be HORIZONTAL or VERTICAL.
reverseLayout When set to true, layouts from end to start.
所以我只声明 LinearLayoutManager 如下:
LinearLayoutManager layoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, true);
一切正常。