Can't get android layout to do what I want - android

I've spent years working with GridBagLayout in java, so I thought setting up a simple layout would be easy. After hours of fiddling with nested LinearLayouts, reading tutorials, and looking at RelativeLayout, I'm getting nowhere.
Below is what I want my main menu to look like. I assume this is possible to do, but many things do not make sense to me, for instance increasing weights seems to decrease the amount of space that a View takes up?
One thing I'm considering doing is just using a relative layout, laying everything else without caring about sizes, and then just setting the sizes in my onCreate since I'll know the size of the display and I can just set each element a certain number of pixels. Is that considered bad practice?
I'm just trying to create a layout with a title on top (the text as large it is can be to fill the width of the screen). That should take up the top 30%. Then the next 50% contains two buttons on the left, an area where I want to draw some animations (I assume using a SurfaceView is a good idea), and then two more buttons on the right.
The remaining 20% will be for a banner ad once I figure out how to add those in.
Is this possible to do? Can anyone show me some XML for this?

So thanks to Alok Nair, this was not hard to do ... I just had to set the sizes to 0px and let the layout weights take care of the sizing.
This is what it ended up being:
<LinearLayout
android:background="#drawable/main_menu_background"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="top"
android:id="#+id/mainSectionMenu"
>
<TextView
android:layout_width="match_parent"
android:layout_height="0px"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="LUNA PUMA"
android:id="#+id/mTitleText"
android:layout_gravity="center"
android:textColor="#ffffffff"
android:autoText="false"
android:textSize="50dp"
android:layout_weight=".3"
android:gravity="center"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight=".5">
<LinearLayout
android:orientation="vertical"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight=".25">
<Button
android:layout_width="wrap_content"
android:layout_height="0px"
android:text="Easy"
android:id="#+id/mEasyButton"
android:layout_gravity="center"
android:layout_weight=".5"
android:background="#android:color/transparent"
android:textColor="#ff000000"/>
<Button
android:layout_width="wrap_content"
android:layout_height="0px"
android:text="Medium"
android:id="#+id/mMediumButton"
android:layout_gravity="center"
android:layout_weight=".5"
android:textColor="#ff000000"
android:background="#android:color/transparent"/>
</LinearLayout>
<SurfaceView
android:layout_width="0px"
android:layout_height="match_parent"
android:id="#+id/mAnimationSurfaceView"
android:layout_weight=".5"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight=".25"
>
<Button
android:layout_width="wrap_content"
android:layout_height="0px"
android:text="Hard"
android:id="#+id/mHardButton"
android:layout_gravity="center"
android:layout_weight=".5"
android:textColor="#ff000000"
android:background="#android:color/transparent"/>
<Button
android:layout_width="wrap_content"
android:layout_height="0px"
android:text="More ..."
android:id="#+id/mMoreButton"
android:layout_gravity="center"
android:layout_weight=".5"
android:background="#android:color/transparent"
android:textColor="#ff000000"/>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight=".2">
</FrameLayout>
</LinearLayout>

You will have to use a combination of layouts, and to achieve this you can use either use android:layout_weight parameters to your views or use Android Percent Support Library.
With layout_weight you can specify a size ratio between multiple views. E.g. you have a view1 and a view2. The view1 should use 3/4 of the screen and view2 should use 1/4 of the screen. Then you will set the layout_weight of the view1 to 3 and the layout_weight of the view2 to 1.
To get it work you also have to set the height or width (depending on your orientation) to 0px.
The Android Percent Support Library allows to specify dimensions of views in terms of percentages instead of absolute numbers, or weights.
The library consists of two main layouts which allow nested views to specify percentage based layouts: PercentRelativeLayout and PercentFrameLayout which work much like their non-Percent counterparts.
Once you've incorporated one of these containers into your layout you can then specify attributes in percentages such as app:layout_widthPercent or app:layout_marginTopPercent="25%".
For using it in your app, just add percent support library to your project
dependencies {
compile 'com.android.support:percent:22.2.0'
}
Here is an example layout using this lib:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
style="#style/match"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
style="#style/block"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<android.support.percent.PercentRelativeLayout
android:layout_marginTop="?attr/actionBarSize"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="#+id/row_one_item_one"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:background="#5182bb"
app:layout_heightPercent="15%"
app:layout_widthPercent="30%" />
<View
android:id="#+id/row_one_item_two"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_toRightOf="#+id/row_one_item_one"
android:background="#396190"
app:layout_heightPercent="15%"
app:layout_widthPercent="30%" />
<View
android:id="#+id/row_one_item_three"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_toRightOf="#+id/row_one_item_two"
android:background="#8fb5e1"
app:layout_heightPercent="15%"
app:layout_widthPercent="40%" />
<View
android:id="#+id/row_two_item_one"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#+id/row_one_item_one"
android:background="#d89695"
app:layout_heightPercent="15%" />
<View
android:id="#+id/row_three_item_one"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_two_item_one"
android:background="#f9c093"
app:layout_heightPercent="20%"
app:layout_widthPercent="40%" />
<View
android:id="#+id/row_three_item_two"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_two_item_one"
android:layout_toRightOf="#+id/row_three_item_one"
android:background="#948957"
app:layout_heightPercent="10%"
app:layout_widthPercent="60%" />
<View
android:id="#+id/row_four_item_one"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_three_item_one"
android:background="#ccc2d9"
app:layout_heightPercent="20%"
app:layout_widthPercent="40%" />
<View
android:id="#+id/row_four_item_two"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_three_item_two"
android:layout_toRightOf="#+id/row_four_item_one"
android:background="#c3d59e"
app:layout_heightPercent="25%"
app:layout_widthPercent="60%" />
<View
android:id="#+id/row_five_item_one"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_four_item_one"
android:background="#948957"
app:layout_heightPercent="10%"
app:layout_widthPercent="40%" />
<View
android:id="#+id/row_five_item_two"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_four_item_two"
android:layout_toRightOf="#+id/row_five_item_one"
android:background="#e6e0ec"
app:layout_heightPercent="10%"
app:layout_widthPercent="60%" />
<View
android:id="#+id/row_six_item_one"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_five_item_one"
android:background="#f9c093"
app:layout_heightPercent="20%"
app:layout_widthPercent="20%" />
<View
android:id="#+id/row_six_item_two"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_five_item_one"
android:layout_toRightOf="#+id/row_six_item_one"
android:background="#588fd3"
app:layout_heightPercent="20%"
app:layout_widthPercent="20%" />
<View
android:id="#+id/row_six_item_three"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/row_five_item_two"
android:layout_toRightOf="#+id/row_six_item_two"
android:background="#a6a6a6"
app:layout_heightPercent="25%"
app:layout_widthPercent="60%" />
</android.support.percent.PercentRelativeLayout>
You can get idea from this and use it to implement for your design requirements.

Related

Scaling an image related to width

I have one main linear layout with orientation set to vertical. It contains two linear layouts, first with layout_weight = 0.25 and the second with value layout_weight = 0.75. The first layout has horizontal orientation and also has two objects ImageView with value layout_weight = 0.5 and EditText with value layout_weight = 0.5.
Here is the full code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- top layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:orientation="horizontal" >
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
app:srcCompat="#drawable/samurai" />
<EditText
android:id="#+id/text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_weight="0.5"
android:background="#android:color/transparent"
android:gravity="bottom|right"
android:inputType="none"
android:maxLines="1"
android:text=""
android:textColor="#color/text"
android:textSize="50sp" />
</LinearLayout>
<!-- bottom layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.75"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
My question is how can i scale the image to match the width, but to auto-scale the height?
To crop the image according to your expected result, you probably have to use a custom matrix for the imageview. I think this is the simplest implementation for TOP_CROP which you can modify for your needs:
https://stackoverflow.com/a/38049348/7554387
The problem is you add 0 to some layout_width and layout_height. Change to 0dp and it should work.
In this case,you should use ConstraintLayout as it can reduce nested layout and surely improve your layout performance.
With ConstraintLayout,code would be.
<android.support.constraint.ConstraintLayout
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">
<ImageView
android:id="#+id/img"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="#drawable/samurai"
app:layout_constraintHeight_percent="0.25"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5"/>
<EditText
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHeight_percent="0.25"
app:layout_constraintStart_toEndOf="#id/img"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/img"/>
</android.support.constraint.ConstraintLayout>

Evenly spacing buttons with layout_weight but having a maxWidth

I have 4 buttons that I space out evenly using layout_weight="1" and layout_width="0dp". However, on large tablet layouts the buttons are too spread out and looks ugly, so I want to set a maxWidth for all of them, and having empty spaces on both sides of the entire LinearLayout instead (so the four buttons are clustered to the center). However, crawling through StackOverflow, many say they don't work together. Is there a way for me to achieve what I want to do above?
tl;dr:
Below a certain width (say, 100dp), all 4 buttons are spaced evenly.
If layout requires buttons to be bigger than 100dp, all 4 buttons are set to 100dp width and stick together, leaving space on both sides of the layout.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/layout_height"
android:background="#drawable/layout_background"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/button_background"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/button_background"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/button_background"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/button_background"/>
</LinearLayout>
Try this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/layout_height"
android:background="#drawable/layout_background"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxWidth="100dp"
android:background="#color/button_background"/>
</LinearLayout>
</LinearLayout>
A simple hack could be
Wrap your button with a Linear layout and set weight to this layout
Set max width to button inside this sub layout
try this one `
<Button
android:background="#color/button_background"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:layout_width="0dp" />
<Button
android:background="#color/button_background"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:layout_width="0dp" />
<Button
android:background="#color/button_background"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:layout_width="0dp" />
<Button
android:background="#color/button_background"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:layout_width="0dp" />
`
add margin to each button as you want .

Align multipile images evenly horizontaly

I have 2 image views in a linear layout like so:
<LinearLayout
style="#style/home_icon_row"
android:orientation="horizontal">
<ImageView
android:id="#+id/ibtn_home_bus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ico_bus_selector" />
<ImageView
android:id="#+id/ibtn_home_butoday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ico_butoday_selector" />
</LinearLayout>
How can i align the two images so that they are evenly placed within the linear layout. Something similar to "justified text" so that it has equal spacing on the left and right of the image from each other and the border of the screen.
it's not the best solution, but it should work:
<LinearLayout
style="#style/home_icon_row"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="0dp"
android:enable="false"
android:focussable="false"
android:clickable="false"
/>
<ImageView
android:id="#+id/ibtn_home_bus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ico_bus_selector" />
<View
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="0dp"
android:enable="false"
android:focussable="false"
android:clickable="false" />
<ImageView
android:id="#+id/ibtn_home_butoday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ico_butoday_selector" />
<View
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="0dp"
android:enable="false"
android:focussable="false"
android:clickable="false" />
</LinearLayout>
if this is for some kind of landing it's ok but if it's a hard used layout think about implementing it dinamically via javacode to make it faster.
EDIT: i added 3 attributes ( enable, focussable, clickable ) to disable the placehodler view so that they'll be considered only at measures/layout time, but not during events handling.
// try this way here is alternative to use two sub linear layout rather three View.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/home_icon_row"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:id="#+id/ibtn_home_bus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ico_bus_selector" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:id="#+id/ibtn_home_butoday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ico_butoday_selector" />
</LinearLayout>
</LinearLayout>
You should be able to get similar effect by using layout_width="0dp", layout_weight="1" and scaleType="centerInside" for both ImageViews.
The only difference is that space between the images can be bigger.
<LinearLayout
style="#style/home_icon_row"
android:orientation="horizontal"
android:padding="#dimen/padding">
<ImageView
android:id="#+id/ibtn_home_bus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ico_bus_selector"
android:layout_marginRight="#dimen/padding"/>
<ImageView
android:id="#+id/ibtn_home_butoday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ico_butoday_selector" />
</LinearLayout>

Is there a way to offset a view from center?

I'm trying to possition my button not exactly in center, but let's say in the 2/5s of the screen height, I was looking for attribute unsuccessfully, so I tried this approach
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:padding="20dp" >
<ImageButton
android:id="#+id/flashlight_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="#+id/fakeView"
android:background="#null"
android:contentDescription="#string/flashlight_button_description"
android:src="#drawable/freeml_bright" />
<View
android:id="#+id/fakeView"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerInParent="true"
android:background="#FFAABB" />
</RelativeLayout>
However it does not work, even if I set margin on the fake view.
Padding attribute works, however as it is a big image and if I want it to start at 2/5ths of screen height, it covers the center point of screen, so if I use padding attribute it works but it pushes it away from center and does not allow it to cover it.
Alhough, I made it work using LinearLayout, which I wanted to avoid because there are more Views on top and bottom next to each other so it would lead to nested views using linear layout. Unfortunately I think its the only option.
It basically it uses another linear layout that fills the remaining space left unused by top and bottom views with height=0dp and weight=1 and sets its gravity to center.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/application_logo_description"
android:src="#drawable/mylight" />
<ImageButton
android:id="#+id/settings_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="#null"
android:contentDescription="#string/settings_button_description"
android:src="#drawable/settings_button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageButton
android:id="#+id/flashlight_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:contentDescription="#string/flashlight_button_description"
android:src="#drawable/flashlight_button_selector" />
<View
android:id="#+id/fakeView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="60dp"
android:background="#FFAABB" />
</LinearLayout>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:contentDescription="#string/powered_by_description"
android:src="#drawable/powered_by" />
<ImageButton
android:id="#+id/ad_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="#null"
android:contentDescription="#string/ad_button_description"
android:src="#drawable/freeml" />
</LinearLayout>
Depending on the screen size of the target device, padding by X dp might move it more than just a fifth of the height.
You might have to code this movement yourself. However, nothing prevents you from doing:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:padding="20dp" >
<View
android:id="#+id/fakeView"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerInParent="true"
android:background="#FFAABB" />
<ImageButton
android:id="#+id/flashlight_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="#+id/fakeView"
android:marginBottom="50dp"
android:background="#null"
android:contentDescription="#string/flashlight_button_description"
android:src="#drawable/freeml_bright" />
</RelativeLayout>
Don't use margin, use padding (top), like so:
<View
android:id="#+id/fakeView"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerInParent="true"
android:paddingTop="80dp"
android:background="#FFAABB" />
That should work, though I've not tested it!
try using attribute android:layout_toLeftOf="#+id/fakeView"

How to: Layout fixed size components with justified spacing

When I have 1, 2 or 3 components I know how to get them to space properly. But now I have a view that will have 4, 5, ... components in it. Rather than increasing the size of the components (via weight), I need them to remain a fixed size. So... is there any way to lay these out with justified spacing (evenly spaced within the view)?
Thanks,
J
A similar work around that I've figured out is to add spacer view components. Again, this is not ideal, but it works. If there is anything better, please let me know.
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<biz.mycompany.mycomponent
android:layout_width="#dimen/screen_view_w"
android:layout_height="#dimen/screen_view_h"
/>
<View
android:layout_width="0px"
android:layout_height="#dimen/main_screen_button_h"
android:layout_weight="1"
/>
<biz.mycompany.mycomponent2
android:layout_width="#dimen/screen_view_w"
android:layout_height="#dimen/screen_view_h"
/>
<View
android:layout_width="0px"
android:layout_height="#dimen/screen_view_h"
android:layout_weight="1"
/>
<biz.mycompany.mycomponent3
android:layout_width="#dimen/screen_view_w"
android:layout_height="#dimen/screen_view_h"
/>
</LinearLayout>
Something like the following would work, but is not necessarily the most efficient way. What type of components are you wanting to insert? Basically, I created a horizontal LinearLayout, with child LinearLayouts with even weights. I set the gravity of these inner LinearLayouts to center their children within, so then your fixed width views go within at their proper sizes, centered evenly within.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
>
<View
android:id="#+id/fixed_view_1"
android:layout_width="30dp"
android:layout_height="50dp"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
>
<View
android:id="#+id/fixed_view_2"
android:layout_width="30dp"
android:layout_height="50dp"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
>
<View
android:id="#+id/fixed_view_3"
android:layout_width="30dp"
android:layout_height="50dp"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
>
<View
android:id="#+id/fixed_view_4"
android:layout_width="30dp"
android:layout_height="50dp"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
>
<View
android:id="#+id/fixed_view_5"
android:layout_width="30dp"
android:layout_height="50dp"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
>
<View
android:id="#+id/fixed_view_6"
android:layout_width="30dp"
android:layout_height="50dp"
/>
</LinearLayout>

Categories

Resources