in a fragment I have a ViewPager that instantiate views (viewpager is the top left white box, the view is the blue box with "AAAAA" inside, padded by 20dp):
The viewpager is "match_parent" inside his fragment. How to "shorten" the width of the containers of the viewpager to achieve a layout like this?
Done! setPageMargin with a negative value & padding inside the view! :)
Related
This is an example of my activity with element fixed and automatic margin:
But when use fragment:
Its possibile to set margin on fragment?
In the fragment container in your activity xml, set padding to the container. In your specific case, set it to the ViewPager.
example:
android:padding="10dp"
Try providing margin to the container you are using to contain your fragment.
for eg. if you are using the framelayout as a container give margin to the frame layout.
I have a Activity with a layout that is a Vertical LinearLayout with a RelativeLayout, ListView, and another RelativeLayout. My problem is if the ListView is longer than the screen, the bottom RelativeLayout will be unreachable. How can I ensure the last RelativeLayout is always at the end of the ListView? Can I make it part of the ListView somehow?
If you want the Bottom RelativeLayout to be fixed use the root element as RelativeLayout and use alignParentBottom = true to bottom RelativeLayout and position ListView below top relative layout and above bottom relativelayout.
if the bottom Relativelayout has to scroll as you scroll listview add it as a footer to the listview.Checkout this on how to add a footer to listview.
i suggest you to use recyclerview instead of ListVIew
I would like to hide my Tablayout in some Fragments my app will show up. One solution would be setting the android:aylout_height attribute of the TabLayout to eiher "0dp" or "wrap_content". But how do I set the height to 0dp programmatically? Is that even possible with a TabLayout?
In the fragments that you want your TabLayout to not show...
tabLayout.setVisibility(View.GONE);
I would put the above part of your code in your fragment's onCreateView() method.
Then, in fragments where you want it to show again:
tabLayout.setVisibility(View.VISIBLE);
xml:
android:visibility="gone"
code:
TableLayout layout= (TableLayout ) view.findViewById(R.id.layout_table);// change id here
layout.setVisibility(View.GONE); //VIEW.VISIBLE etc.
I need display a Layout on botton of ScrollView such as:
1 - If the height of the content of the ScrollView is less than the height of the ScrollView, the Layout should be at the bottom of the ScrollView
2 - If the height of the content of the ScrollView is greater than the height of the ScrollView, then the Footer Layout should hide and only show Title.
When user scroll up to end of content, then Layout footer also scroll follow content.
PS: I'm using scrollview and must use it for my project.
My android page has 10 EditText and 10 TextView. but there is no space in my screen in the Graphical Layout. i just added 5 only. im using Scroll layout. how to add additional 5 items in the screen without reducing the items height. Is there any coding here.?
<ScrollView>
<LinearLayout>
<TextView/>..
....
..
</LinearLayout>
</ScrollView>
You can add multiple items inside a LinearLayout. Since ScrollView is scrollable it won't affect the dimensions of the Views inside. You can add as many views as you need without worrying about screen size or View size..
You should add a LinearLayout as the only child inside your ScrollView. Then get a reference to that LinearLayout :
mLayout=(LinearLayout)findViewById(R.id.myLayout);
and then add Views dynamically from code using :
EditText et=new EditText(...);
//....
mLayout.addView(et);
A ScrollView can have only one direct child, so you need to put all the other Views in a Layout, such as LinearLayout and put that layout in ScrollView
Make your ScrollView's height as match_parent and the inner LinearLayout's height as wrap_content. The LinearLayout will stretch according to the number of children inside it and if the height exceeds the height of the ScrollView, the overflow can be seen by scrolling. If the ScrollView and inner Layout both have same height or if ScrollView have larger height than inner Layout, the scrolling won't happen for obvious reason.