0

I have an activity layout that includes my fragment container this way,

<include layout="@layout/content_main" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/background_container" /> 

and my fragment container is compose of linearlayout and a framelayout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:padding="10dp"> <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" /> </LinearLayout> 

The problem is that I have to add my scrollable fragment in this container but the scroll doesnt seem to work. My layout goes like this

<ScrollView 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:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> ... ... </LinearLayout> </ScrollView> 

I have tried several answer like

  1. Using NestedScrollView
  2. Adding minimum height to framelayout
  3. Using fillViewport="true"
  4. etc.

But nothing seems to work. Any idea what I've been doing wrong? Any help would be appreciated. Thanks in advance! Cheers!

Edit:

My activity layout contains navigation drawer, i dont know if it matter. And i add the view using

ft.replace(R.id.fragment_container, myFragment).commit(); 

i also dont know if fragment replace messes with my view. Please help. Thanks

3
  • android:layout_height="match_parent" for framelayout in your container. Commented Jul 17, 2018 at 6:22
  • @RajSuvariya i have done that, nothing. Thanks Commented Jul 17, 2018 at 6:26
  • @pskink im not familiar with that, can you enlighten me or give links about what you mean? thanks Commented Jul 17, 2018 at 6:26

1 Answer 1

2

it seems my fragment container's LinearLayout is missing orientation and also frameLayout android:layout_height should be match_parent

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:orientation="vertical" // orientation android:padding="10dp"> <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" // match_parent android:background="@android:color/transparent" /> </LinearLayout> 
Sign up to request clarification or add additional context in comments.

2 Comments

nothing.. i had also tried changing that linear to scrollview and nestedscrollview but still nothing. thanks
@pskink im reading and still trying to understand it.. I get adb is not recognize as command

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.