i created a button, which changes the visibility of a textview.
Both are in a ScrollLayout and a vertical LinearLayout:
ScrollLayout
LinearLayout
...some other views...
Button
TextView
/ScrollLayout
/LinearLayout
On start of the activity the TextView visibility is set to "gone", so the Button is at the bottom of the screen.
My Problem now is that if i click on the Button and the TextView gets "visible" i have to scroll down to see the textview. I want it to scroll by itself to the TextView.
This should do the trick I think,
scroll.fullScroll(View.FOCUS_DOWN)
Related
How can I set the visibility of a grid layout from INVISIBLE to VISIBLE in android studio.
Look at this what i'd tried-
public void verifyOTP(View view){ //verifyOTP is button onclick method
GridLayout gridLayout = (GridLayout) findViewById(R.id.gridLayout);
gridLayout.setVisibility(View.VISIBLE);
}
This doesn't worked for me. i.e. when i press the verifyOTP button, the layout is not reset to VISIBLE from INVISIBLE.
please suggest some solution.
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
Have LinearLayout with few buttons in it.
Initially visibility is set to View.GONE but after user clicks, visibility is set to VISIBLE
This is where I need to programmatically detect one of button's width and match other button width to it.
initial call to
public void onWindowFocusChanged(boolean hasFocus)
does not work since the this layout is initially not visible.
getMeasuredWdith() and getWidth()
return 0 when called after visibility flags has been changed.
Any ideas to get get width of this button?
figured it out.
ended up going back to xml.
each row of buttons got their own LinearLayout.
wrapped all button rows in a parent LinearLayout.
Set parent and leading button (to which I'll be matching widths of other buttons) layout_width to "wrap_content"
Set other button rows' layout_widths to 'fill_parent'
done.
I have this layout:
It was a bit tricky to put ListView inside ScrollView, but it worked.
When the list is large and the scroll appears when scrolling .. everything up, including the form. That is ok!
Now I would like to put a TextView fixed at the bottom of the screen. As a total
Tried to wrap everything with a RelativeLayout put layout_weight = "1" in ScrollView. Worked. But when the keyboard appears, rises along the TextView and do not want it.
How do I set a TextView at the bottom of the screen, without moving when the keyboard appears?
Put everything in a relative layout. Add the TextView to the relative layout, set layout_alignParentBottom on TextView. Then on the ScrollView set layout_above referencing the TextView.
Follow the design hierarchy:
<LinearLayout.....>
<ScrollView>
<You Old Views/>
</ScrollView
<TextView> .. </TextView>
</LinearLayout>
In a RelativeLayout I have a Button to the right of a TextView. The problem is that the text view gets squished to the left of the screen. I want the Button to be squished to the right and the TextView take up all the remaining space. I can't use 'Fill Layout' on the TextView because the button then gets removed from the View completely.
How do I do this?
Give your TextView android:layout_weight="1".