0

I am having a word file which contain some text I am getting that text in array list base on lines.

BufferedReader reader = null;

try {
    reader = new BufferedReader(
        new InputStreamReader(getAssets().open("surah1.txt"), "UTF-8"));
    // do reading, usually loop until end of file reading

    String mLine;

    while ((mLine = reader.readLine())!= null ) {
        surah1.add(mLine);
        //process line
    }

    Log.i("TAG", "onCreateView: " + surah1);
} catch (IOException e) {
    e.printStackTrace();
} finally {
    if (reader != null){
        try {
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

When I am displaying it using RecyclerView it is either displaying in horizontal format or vertical format. But I want display it in paragraph format.

listView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, true));

madapter = new testingAdapter(testing.this,surah1);
listView.setAdapter(madapter);

Actually what i want is when ever user click on the line i want to change that hole line color and also if user want to share he can share it. so thats the reason i am changing text file to array list. if any one is having any idea please help me out.

example: In this image i am displaying that text by web view. but i want to display it base on lines so that when ever i click on line i can change that line color and share it.

i want it to be like this

but getting this when RecyclerView is in vertical format

GianhTran
  • 3,443
  • 2
  • 22
  • 42

1 Answers1

0

You just need to style your recyclerview item layout. Try removing margin/padding from the item layout.

Mahmoud Elshamy
  • 578
  • 1
  • 5
  • 13
  • but i want that item layout textview to be displayed side by side completely merged as u can see in first image – syed raheem Jan 02 '19 at 07:33
  • I think this can't be achieved by RecyclerView. Try using flow layout so views is flowed side by side like this library: https://github.com/ApmeM/android-flowlayout – Mahmoud Elshamy Jan 02 '19 at 07:36
  • You can achieve it with ClicableSpan too. But I think it will be some complex. Take a look to this answer so you can add ClickableSpan to a single TextView: https://stackoverflow.com/a/34541570/2016500 – Mahmoud Elshamy Jan 02 '19 at 07:40