首页 > 解决方案 > 如何在更改电话语言时反转我的回收站视图但不改变方向?

问题描述

在这段代码中:-我试图从(从右到左水平转换)反转我的recyclerview,它运行良好但是在更改我的手机语言时它变成了(从左到右)如何解决这个问题?我的意思是总是(从右到左)不管改变语言。

public class QuranSafhaListActivity extends AppCompatActivity {

RecyclerView recyclerView;
QuranSafhaListAdapter quranSafhaListAdapter;
LinearLayoutManager linearLayoutManager;
List<SafhaListItems> safhaListItems;
static int position;
String path;
Bitmap bitmap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quran_safha_list);
    getSupportActionBar().hide();

    safhaListItems = new ArrayList<>();
    recyclerView = (RecyclerView) findViewById(R.id.safhaofmoshafrecyclerview);

    linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
    linearLayoutManager.setReverseLayout(true);
    recyclerView.setLayoutManager(linearLayoutManager);

    position = getIntent().getIntExtra("Position", 0);
    path = Integer.toString(position);

    try {
        safhaListItems = readMoshafPages(path);
    } catch (IOException e) {
        e.printStackTrace();
    }

    // safhaListItems.add(new SafhaListItems(bitmap));
    quranSafhaListAdapter = new QuranSafhaListAdapter(this, safhaListItems);
    recyclerView.setAdapter(quranSafhaListAdapter);


    SnapHelper snapHelper = new LinearSnapHelper();
    snapHelper.attachToRecyclerView(recyclerView);
}

public ArrayList<SafhaListItems> readMoshafPages(String path) throws IOException {
    ArrayList<SafhaListItems> bitmaps = new ArrayList<>();
    AssetManager assetManager = getAssets();

    String[] files = assetManager.list("QuranSora" + "/" + path);

    for (int i = 0; i < files.length; i++) {

        Bitmap bitmap;
        InputStream istr = assetManager.open("QuranSora" + "/" + path + "/" + files[i]);
        bitmap = BitmapFactory.decodeStream(istr);
        bitmaps.add(new SafhaListItems(bitmap));
    }

    return bitmaps;
}

}

标签: android

解决方案


<application
...        
    android:supportsRtl="false"
...
</application>

添加android:supportsRtl="false"到 AndroidManifest.xml 的应用程序标签中


推荐阅读