left one is the mobile phone and right one is the device on android studio.
Use linear layout (horizontal) inside your relative layout and add buttons to it
Set linear layout's attribute weight_sum to number of buttons in a row (for example 5)
Set buttons' attribute layout_weight instead of explicitly defining size in dp (for example 1 for each button)
Duplicate your linear layout for all the rows
Profit
Related
The scenario:
10 buttons in an linear layout using layoutweight: 1
The result i want:
The buttons should fill the linear layout by adapting their margin.
Failed attempt:
I tried setting, for the linear layout, the attribute weightsum: 11 (number of buttons + 1) in the hope that the remaining 11 - 10 would be used as a margin divided to all the buttons (1/10 margin for each button)
You might want to try a ConstraintLayout, if you constraint all buttons to each other they will spread out evenly inside the ViewPort.
Top<-B1<->B2<->B3...B10->Bottom
How can I achieve this layout?
Use a FrameLayout that act as a parent of a LinearLayout( say layout ll_par) & an ImageView..In your ll_par add your two remaining layout .& remember put the Imageview as the last child of FrameLayout & set its layout_gravity to right|center_vertical & give some margin to your Imageview according to the need ..
Need to put an information layout above the others.. but the half up of layout 3, is below the layout 1..
what i need.. layout 3 above the others, and in the center of the padding
what i have.. layout 1 above 3, and layout 3 above layout 2
using RelativeLayout i get layout 3 below the others, the opposite.
is there an option or something like bring to front??
Any other clue?
Thanks!
Each View's position on the Z-axis is dependent on its order in the XML file. Try placing the layout you want on top after the other two layouts in your XML file. If you want to change the View's position in your java code, you can use
view.bringToFront();
http://developer.android.com/reference/android/view/View.html#bringToFront%28%29
I have a Linear Layout with many linear layouts inside. At runtime , I want to remove this layout(along with its child linear layouts) from the view subject to a condition. On removal, I want other layouts to be adjusted accordingly.
I tried this, but the layout remains.
if(getIntent().getStringExtra("ListingType").equals("Brief")){
extraLayout.setVisibility(View.GONE);
extraLayout.removeAllViews();
}
This Activity has 2 main Linear Layouts, 1 is DetailsLayout and 2 is ExtraLayout, both these layouts are relative to each other in a ScrollView. The main(root) layout of the Activity is Relative Layout
What's the best approach to have a layout with the following:
Spinner (default height)
WebView (all the space between the two views (Spinner and Button))
Button (default height)
How is it possible to specify the height of the WebView to take all the space between the two (i.e. if they are resized later, the WebView will automatically be adjusted).
Thanks!
Use a RelativeLayout as the parent layout. Align the Spinner to the top of the parent. Align the Button to the bottom of the parent. For the WebView, set the height as match_parent and then use the android:layout_below and android:layout_above attributes to make sure that it always lies between the two views.
(I would've given the code but I don't want to. You might just copy paste with zero learning.)