Android UI Screen - android

Good Day,
I'm new in Android UI development. May I have any knowledge on how will I achieve this kind of UI Screen:
Thanks in advance.

Here is the code with TextView.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/upparLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#9DAD0C"
android:orientation="horizontal"
android:weightSum="3">
<TextView
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#9DAD0C"
android:text="Tab1" />
<TextView
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#717D11"
android:text="Tab2" />
</LinearLayout>
<TextView
android:id="#+id/screen1"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/upparLayout1"
android:background="#CD5E93"
android:text="Screen1" />
<LinearLayout
android:id="#+id/middleLayout"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_below="#+id/screen1"
android:background="#9F165A"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_weight="1"
android:text="SubTab1" />
<TextView
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_weight="1"
android:text="SubTab2" />
</LinearLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_below="#+id/middleLayout"
android:background="#A9BB2B"
android:text="List Based on Sub Tab" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_below="#+id/textView2"
android:layout_centerHorizontal="true"
android:background="#A9BB2B"
android:text="List Based on Sub Tab" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_below="#+id/textView3"
android:layout_centerHorizontal="true"
android:background="#A9BB2B"
android:text="Button" />
</RelativeLayout>

You can find all you need in creating that layout in the following links:
Google Play Style Tabs using TabLayout (Android M)
Action Bar Tabs
As for the layout of each tab you can do something like this (as structure)
<RelativeLayout>
<LinearLayout> // or you can use a fragment
//Screen 1 content
</LinearLayout>
<SubTabs>
<SubTabs>
</RelativeLayout>
For the sub-tab content:
<?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:weightSum="2">
<ListView
android:id="#+id/list1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="10dp"/> //replace margin with your value
<ListView
android:id="#+id/list2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="10dp"/> //replace margin with your value
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</LinearLayout>

Related

Android dialog with ListView

I have a problem with a dialog with some buttons and a ListView.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black"
android:orientation="vertical"
tools:context=".MyApplicationActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/selectContactRecord"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white" />
<Button
android:id="#+id/btnContactPickerAdd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawableLeft="#android:drawable/ic_menu_add"
android:drawableStart="#android:drawable/ic_menu_add"
android:text="#string/noContact" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:text="#string/selectBulbs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white" />
<ListView
android:id="#+id/listViewCallRecordsDetail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#drawable/gradient"
tools:listitem="#layout/callrecord_detail_list_item" >
</ListView>
<Button
android:id="#+id/btnTestAddRecord"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:drawableLeft="#drawable/test_bulbs"
android:drawableStart="#drawable/test_bulbs"
android:text="#string/test" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:background="#android:color/black"
android:orientation="horizontal" >
<Button
android:id="#+id/btnCancelAddRecord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="#android:drawable/ic_menu_revert"
android:drawableStart="#android:drawable/ic_menu_revert"
android:text="#string/cancel" />
<Button
android:id="#+id/btnSaveAddRecord"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableLeft="#android:drawable/ic_menu_save"
android:drawableStart="#android:drawable/ic_menu_save"
android:text="#string/save" />
</LinearLayout>
The problem is now, if I have a lot of records in the ListView, the button below disappears and it is not possible to scroll down.
I tried this with a ScrollView, but failed because it is not possible to use that with a ListView.
I want that the buttons below the listview always stay at the bottom and that the ListView is scrollable.
Can somebody please give me a hint?
Change your list view to this:
<ListView
android:id="#+id/listViewCallRecordsDetail"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="#drawable/gradient"
tools:listitem="#layout/callrecord_detail_list_item"
It'll make sure the button is layout in the bottom and, the list view take all the height remain
You want this :
I want that the buttons below the listview always stay at the bottom
and that the ListView is scrollable.
For this change this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black">
<TextView
android:id="#+id/tvContactRecord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/selectContactRecord"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white" />
<Button
android:id="#+id/btnContactPickerAdd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawableLeft="#android:drawable/ic_menu_add"
android:drawableStart="#android:drawable/ic_menu_add"
android:text="#string/noContact"
android:layout_below="#+id/tvContactRecord" />
<TextView
android:id="#+id/tvSelectBulbs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:text="#string/selectBulbs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white"
android:layout_below="#+id/btnContactPickerAdd" />
<ListView
android:id="#+id/listViewCallRecordsDetail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#drawable/gradient"
tools:listitem="#layout/callrecord_detail_list_item"
android:layout_below="#+id/tvSelectBulbs"
android:layout_above="#+id/btnTestAddRecord" >
</ListView>
<Button
android:id="#+id/btnTestAddRecord"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:drawableLeft="#drawable/test_bulbs"
android:drawableStart="#drawable/test_bulbs"
android:text="#string/test"
android:layout_above="#+id/llBottom" />
<LinearLayout
android:id="#+id/llBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:background="#android:color/black"
android:orientation="horizontal"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/btnCancelAddRecord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="#android:drawable/ic_menu_revert"
android:drawableStart="#android:drawable/ic_menu_revert"
android:text="#string/cancel" />
<Button
android:id="#+id/btnSaveAddRecord"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableLeft="#android:drawable/ic_menu_save"
android:drawableStart="#android:drawable/ic_menu_save"
android:text="#string/save" />
</LinearLayout>
</RelativeLayout>
You can consider below layout for the solution. You can replace Buttons as per your need.(I have given 2 buttons to simplify the things for you) Also you can also consider taking the buttons in another layout as well if required.
<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"
tools:context="${relativePackage}.${activityClass}" >
<Button
android:id="#+id/btn2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="My Button 2" />
<Button
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/btn2"
android:text="My Button 1" />
<ListView
android:id="#+id/lstMyListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/btn1" />
</RelativeLayout>

Can't get scrollview to work

my code of the XML file I am currently working in! So what I want is to make it possible to scroll in this screen, however there are currently no objects that fall outside of the screen but they will in the future. Hope This gives enough info for help.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="#666666">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Name: "
android:id="#+id/NameView" />
<TextView
android:layout_width="128dp"
android:layout_height="38dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/Name"
android:text="#string/nameString"
android:layout_gravity="center_horizontal"
android:layout_weight="0.75" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Adress:"
android:id="#+id/AdresView" />
<TextView
android:layout_width="128dp"
android:layout_height="38dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/adressString"
android:id="#+id/Adress"
android:layout_gravity="center_horizontal"
android:layout_weight="0.75" />>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="E-mail:"
android:id="#+id/emailView"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="128dp"
android:layout_height="38dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/emailString"
android:id="#+id/Email"
android:layout_gravity="center_horizontal"
android:layout_weight="0.75" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Mobile:"
android:id="#+id/mobileView" />
<TextView
android:layout_width="128dp"
android:layout_height="38dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/mobileString"
android:id="#+id/Mobile"
android:layout_gravity="center_horizontal"
android:layout_weight="0.75" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Edit Profile"
android:id="#+id/BeditProfile"
android:layout_gravity="bottom"
android:layout_marginLeft="240dp"
android:onClick="onButtonClick" />
</LinearLayout>
</ScrollView>
You need to use ScrollView instead of LinearLayout then i will be work.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#666666"
android:orientation="vertical"
android:weightSum="1" >
<!-- Your all XML code paste here -->
</LinearLayout>
</ScrollView>
If you want to make a screen scrollable just use a ScrollView.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
...
...
</LinearLayout>
</ScrollView>
The ScrollView must only have one direct child!
Put everything in one ScrollView and you will be able to scroll everything - so the main LinearLayout should be wrapped in a ScrollView

How to design a xml file to display in more screen

I'm new android programmer, I designed a page screen of 4". I've initialized with "dp" unit of measurement.
but when I run my project in screen of 10" or 7" or 3"2 components go wrong.
I learned dp is for all of screen, but I don't know why my page not be set to all of screens.
If you could include any code of your XML file, that would be very helpful.
Aside from that, I believe you haven't set android:layout_width and android:layout_height so you are getting odd looking sizes for the other display sizes of you XML.
Add
android:layout_width="match_parent"
android:layout_height="match_parent"
to your <RelativeLayout>
e.g.
<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"
...
>
If you do in fact have this or it does not help with your issue
, then please respond with an example of your code.
my xml file is here, but I set visibility of one linearlayout to gone
and when user touch button the linearlayout will be visible and another linearlayout will be gone
<?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:id="#+id/mainLayout"
android:background="#drawable/darirann"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/layoutTerm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<ScrollView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_marginTop="200dp"
android:layout_height="150dp">
<LinearLayout
android:padding="5dp"
android:layout_width="wrap_content"
android:background="#ffffff"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/firstpageabout" />
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/btnLoad"
android:layout_gravity="center"
android:textColor="#ffffff"
android:background="#114E7D"
android:gravity="center"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:text="ادامه"/>
</LinearLayout>
<LinearLayout
android:id="#+id/layoutData"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="gone">
<Spinner
android:id="#+id/spState"
android:paddingRight="5dp"
android:layout_gravity="center"
android:background="#D3D3D3"
android:textSize="12sp"
android:layout_marginTop="200dp"
android:layout_width="150dp"
android:gravity="center"
android:layout_height="40dp" />
<Spinner
android:id="#+id/spCity"
android:paddingRight="5dp"
android:layout_gravity="center"
android:background="#D3D3D3"
android:textSize="12sp"
android:gravity="center"
android:layout_marginTop="5dp"
android:layout_width="150dp"
android:layout_height="40dp" />
<Button
android:layout_gravity="center"
android:id="#+id/btnNext"
android:textColor="#ffffff"
android:background="#114E7D"
android:layout_marginTop="10dp"
android:layout_width="120dp"
android:layout_height="40dp"
android:text="مرحله ی بعد" />
<Button
android:layout_gravity="center"
android:id="#+id/btnUpdate"
android:visibility="invisible"
android:textColor="#ffffff"
android:background="#840101"
android:layout_marginTop="80dp"
android:layout_width="200dp"
android:layout_height="40dp"
android:text="دریافت نسخه ی جدید این برنامه" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgAds"
style="?android:attr/buttonStyleSmall"
android:layout_width="150dp"
android:layout_height="75dp"
android:visibility="gone"
android:layout_gravity="center_horizontal|center"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

popup window layout design left blank space

My popup window design left blank space on top of the window. i try different layout options but space persist.i don't understand how to eliminate this.i am using Custom popup Please help.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#FFF"
android:text="Input a Value"/>
<ImageView
android:id="#+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/severity_rating"
android:layout_marginRight="5dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText
android:id="#+id/popup_et"
android:layout_height="wrap_content"
android:layout_width="100dp"
android:inputType="number" />
<Button
android:id="#+id/dialogButtonOK"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Ok"/>
<Button
android:id="#+id/dialogButtonCancel"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="cancel"/>
</LinearLayout>
</LinearLayout>
use dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
Setting height to fill_parent to the first linear layout doesn't help ?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
Try this..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
and your imageview give as src
<ImageView
android:id="#+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/severity_rating"
android:layout_marginRight="5dp" />
Use android:layout_weight="" for your linearlayout objects and arrange their appearance in window. Use especially for the item which will occupy more space.
Popup Window
for this view, I use
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/popborder_record"
android:orientation="vertical">
<TextView
android:id="#+id/tvCHLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/md_blue_grey_200"
android:text="#string/checklistsetup"
android:textAlignment="center"
android:textSize="#dimen/text_size"
android:textStyle="bold" />
<ListView
android:id="#+id/lvCheckList"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_weight="8" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="#string/lblSoru"
android:textSize="25sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/lblPuan"
android:textSize="25sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
android:layout_weight="9"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="10"
android:inputType="number"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btnAdd"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="#+id/btnCHSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/strSave" />
<Button
android:id="#+id/btnCLClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/strOFF" />
</LinearLayout>
If you use weight on each element with will also cause spaces. So use for object for important.

How to cent image buttons vertically on the action bar

I have made a custom theme to display my image buttons on the action bar. I was wondering how I can center these buttons vertically in android.
The code I have written so far.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left|center_vertical"
android:background="#drawable/groups" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center|fill_vertical"
android:background="#drawable/contactlist" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right|center_vertical"
android:background="#drawable/favourites" />
</FrameLayout>
This is what I want
// try this
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#android:color/holo_blue_dark"
android:padding="5dp"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/groups" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#android:color/white"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#android:color/holo_blue_dark"
android:padding="5dp"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/contactlist" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#android:color/white"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#android:color/holo_blue_dark"
android:padding="5dp"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/favourites" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
Please follow this code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|left|center_vertical"
android:layout_weight="1"
android:background="#FE6602" />
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|center|fill_vertical"
android:layout_weight="1"
android:background="#DBEAF9" />
<ImageButton
android:layout_width="0dip"
android:layout_height="50dip"
android:layout_gravity="top|right|center_vertical"
android:layout_weight="1"
android:background="#FAF2B0" />
</LinearLayout>
Changes:
android:layout_height="50dip" to android:layout_height="wrap_content"
android:background="#FE6602" to android:background="#drawable/contactlist"
I just put simple color and static size or testing purpose work like charm.
You can put the image buttons inside a LinearLayout with vertical orientation, and then set their gravity to android:layout_gravity="center"

Categories

Resources