Adding margins to listview - android

I am following a tutorial and I did not understand why exactly the margins that I applied to a list view contained within a relative layout does not affect the look when I test it on a device. However, if I put everything in a LinearLayout container it looks as it should. I don't understand why the layout does not work without this LinearLayout.
This is my code in layout for my listView:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/inbox_horizontal_margin"
android:layout_marginRight="#dimen/inbox_horizontal_margin"
android:layout_marginTop="#dimen/inbox_vertical_margin"
android:background="#android:color/white">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/messageIcon"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/message_list_item_vertical_margin"
android:paddingBottom="#dimen/message_list_item_vertical_margin"
android:layout_alignParentStart="true"
android:contentDescription="#string/content_desc_message_icon"
android:src="#drawable/ic_action_picture"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/senderLabel"
android:layout_centerVertical="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:layout_toRightOf="#+id/messageIcon"
android:layout_toEndOf="#+id/messageIcon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=" created at: 03.17.15"
android:id="#+id/createdAtLabel"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/senderLabel"
android:layout_toEndOf="#+id/senderLabel"/>
</RelativeLayout>
</LinearLayout>
This is the result of the code:
this is the code without the LinearLayout:
<?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="wrap_content"
android:layout_marginLeft="#dimen/inbox_horizontal_margin"
android:layout_marginRight="#dimen/inbox_horizontal_margin"
android:layout_marginTop="#dimen/inbox_vertical_margin"
android:background="#android:color/white">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/messageIcon"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/message_list_item_vertical_margin"
android:paddingBottom="#dimen/message_list_item_vertical_margin"
android:layout_alignParentStart="true"
android:contentDescription="#string/content_desc_message_icon"
android:src="#drawable/ic_action_picture"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/senderLabel"
android:layout_centerVertical="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:layout_toRightOf="#+id/messageIcon"
android:layout_toEndOf="#+id/messageIcon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=" created at: 03.17.15"
android:id="#+id/createdAtLabel"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/senderLabel"
android:layout_toEndOf="#+id/senderLabel"/>
</RelativeLayout>
And this is the result of this layout:

Margin is outside a view , ListView uses AbsListView.LayoutParams by default, which doesn't include any margin support, just the height and width, thats why, it simply ignores the params value for margins. Try using padding for your relative layout instead

Related

How to center fit image in linear layout?

I have an xml screen with three children linear layouts in a parent linear layout of vertical orientation. First child contains an image view and when running the application I can not view any image. Why? is the image size too big?? If so.. how to scale it? However Image is view able in my design tab. of android stdudio. Below is my complete code for xml file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_sign_up"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.root.my_laoder.SignUp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="#drawable/ty"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingTop="50dp"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp"
>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"/>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
/>
</LinearLayout>
</LinearLayout>
1. Add attribute android:gravity="center_horizontal" to LinearLayout, to show ImageView in center.
2. Update ImageView width to android:layout_width="wrap_content" and remove attribute android:layout_gravity="center".
3. Use android:scaleType="fitXY" instead of android:scaleType="centerInside"
Try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_sign_up"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/ty" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingTop="50dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp">
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
</LinearLayout>
</LinearLayout>
OUTPUT:
what are the dimens values for these parameters?
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
and why you are using separate linearlayout for imageView even with parent layout as linear?
kindly remove that
have you checked the size of image you are using as a background in ImageView? if size is large than probably image is pushing your rest of your views out of the screen.try to give fixed width and height let's say 100dp for both and see if you are able to see anything.
If you wanna make imageView centre horizontally use in ImagView view
android:layout_gravity="center_horizontal"
above line of code will not work with separate linear layout for ImageView. If you are gonna use separate layout for ImageView anyway, use below line of code inside that linearlayout
android:gravity="center_horizontal"
Note: sorry I'm not able to leave a comment.
Try this for your ImageView:
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="#android:drawable/btn_minus" />
I think you missed scaleType of ImageView, Follow the steps to make your image center
1. Add attribute android:layout_gravity="center_horizontal" to show ImageView in center.
2. Set ImageView layout_width="match_parent" and
layout_height="#dimen/fixed_height"
==> height will be fixed but width will automatically adjust
according to device size
3. and set scaleType="fitEnd" or scaleType="fitCenter"
==> fitEnd is ( Scale the image from the end of the container ) and
possible to have space on top
if image is different each time.
==> fitCenter is (Scale the image from center) and possibility to
have space in top and bottom
Example:
<ImageView
android:id="#+id/cover_image"
android:layout_width="match_parent"
android:layout_height="#dimen/fixed_height"
android:layout_gravity="center_horizontal"
android:scaleType="fitEnd" />

Horizontaly center a LinearLayout

I have the following LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/about_vertical_margin"
tools:context=".MainActivity">
<LinearLayout
android:id="#+id/dev_buy_layout"
android:layout_width="wrap_content"
android:layout_height="#dimen/dev_by_layout_height"
android:orientation="horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/dev_buy_text"
android:text="#string/dev_buy_text"
android:layout_width="#dimen/dev_by_width"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin" />
<TextView
android:id="#+id/dev_by_value"
android:text="#string/dev_by_value"
android:layout_width="120dp"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
But it will not center itself, even after looking around for answers, they were of no use so far.
How may I do it?
android:layout_centerHorizontal="true"
This will work fine for you as parent layout is RelativeLayout
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_gravity="center_horizontal"
And Remove These Lines :)
It should work with centerInParent property, as the main parent is a RelativeLayout.
Just do the following:
android:layout_centerInParent="true"
There are two ways you can do it.
First of all remove following lines from LinearLayout
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_gravity="center_horizontal"
First would be add below line inside LinearLayout
android:layout_centerHorizontal="true"
else
Second would be write below line inside RelativeLayout
android:gravity="center_horizontal"

Custom View with text view is not coming

I am inserting custom view inside a relative layout. The action bar turning into white color
Here is the xml code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/dark_tablet_converted"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<com.test.myview
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="8dp" />
<TextView
android:id="#+id/text1"
style="?android:attr/listSeparatorTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:text="text : "
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
and here is the image.
I am not getting where is the problem.
Android support library used
'android support appcompat-v7:23.0.1'
'android.support v4:23.0.1'
targetSdkVersion 23
compileSdkVersion 23
buildToolsVersion '23.0.1'
EDIT:
Whatever placed above my view will get displayed. only if any layout/view is placed below my customview will get vanished.
your views are child of relative layout
so, they are drawed one on the other
and you can't really decide who will be in foreground and who will be in background
add a framelayout as parent of your custom and text view
then, in your code, find your textview and call "bringToFront"
try this,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/dark_tablet_converted"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<com.test.myview
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:padding="8dp" />
<TextView
android:id="#+id/text1"
style="?android:attr/listSeparatorTextViewStyle"
android:layout_below="#+id/view"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:text="text : "
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>

Android: Custom Expandeble List and TextView issue

I faced with one issue when I tried to create my custom Expandable List View.
I can't make text ("9.2") on the center of the cell.
incorrect image
But on the prevew mode it looks fine.
correct image
Here my xml file:
<?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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#android:color/background_dark">
<LinearLayout
android:id="#+id/titles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/space_between_elements"
android:orientation="vertical"
android:layout_toRightOf="#+id/image"
android:layout_toLeftOf="#+id/rate">
<TextView
android:id="#+id/bigTitle"
style="#style/PrimaryFont"
android:text="A big title"/>
<TextView
android:id="#+id/littleTitle"
style="#style/SecondaryFont"
android:layout_marginTop="#dimen/space_between_elements"
android:text="A little title" />
</LinearLayout>
<TextView
android:id="#+id/rate"
style="#style/RatingFont"
android:text="9.2"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="#+id/titles" />
<ImageView
android:id="#+id/image"
android:layout_width="#dimen/touchable_ui_components"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/abc_ic_cab_done_holo_dark"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="#id/titles" />
</RelativeLayout>
I think the main issue due to +id/image becasue without +id/titles it also looks incorrectly.
Try this for the TextView with id rate.
android:layout_centerVertical="true"
Remove
android:layout_alignParentTop="true"
Be careful with the padding, it might move the drawable region not be in the center. (see http://developer.android.com/reference/android/view/View.html ->Size, padding and margins)
Also these two:
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
have similar effects, use only one. I prefer Right
(see http://developer.android.com/reference/android/widget/RelativeLayout.html#ALIGN_PARENT_END)

Button not displayed on emulator or on Device

I am a beginner on Android. I have created 2 activities. First activity has 1 button (say Button1) and 1 TextView (say TextView1) and the Second activity has 1 TextView (say TextView2). The text value for TextView in 1st activity is "Hello World!", when the Button1 is pressed opens up 2nd Activity passing the value of the TextView1 (i.e. "Hell World!"). The 2nd Activity assigns the obtained value to the TextView2 and displays.
All of this is working fine.
When I add a new Button (say Button2) to the 1st activity and write a onClick() method to change the text of TextView1 from "Hello World!" to "Hello Android!" and vice versa. Now when I run this on my device or emulator I cannot see this added button (Button2) it still works as earlier when I click Button1, but I cannot see Button2.
Can anyone help me on this ?
XML Layout : MainActivity
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world" />
<Button
android:id="#+id/ourButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView"
android:layout_below="#+id/textView"
android:layout_marginRight="37dp"
android:onClick="buttonClick"
android:text="#string/button_string" />
<Button
android:id="#+id/ourButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView"
android:layout_below="#+id/textView"
android:layout_marginLeft="50dp"
android:focusable="false"
android:onClick="buttonClick2"
android:text="#string/button_string2" />
</RelativeLayout>
It's because you have android:layout_below="#+id/textView" twice. Try this instead:
<!-- below the previous view : ourButton -->
<Button
android:id="#+id/ourButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/textView"
android:layout_below="#id/ourButton"
android:layout_marginLeft="50dp"
android:focusable="false"
android:onClick="buttonClick2"
android:text="#string/button_string2" />
Also, don't use #+id/ for align your layout. You use it right when you add an id but when the id is created, you just have to align on it as android:layout_toLeftOf="#id/prevId" with #id.
Example:
Here the layout:
|---- text -----|
<- both are below text
|---- view1 ----|| <- view align right
view align left -> ||---- view2 ----|
As you can see, the left and right alignment are on the "border" of the TextView because you set an alignment below the TextView. So it looks like this:
|------ text ------|
<- both are below text
view1 align left -> ||---- view 1&2 ----|| <- view2 align right
Your views are overlapping each other. If you want to have the two buttons below the text and side by side, try to add a container, like this following:
<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:gravity="center_horizontal|center_vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/textView"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/ourButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:onClick="buttonClick"
android:text="#string/button_string" />
<Button
android:id="#+id/ourButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="buttonClick2"
android:text="#string/button_string2" />
</LinearLayout>
</RelativeLayout>
Hope this helps.
Please try to remove
android:layout_marginRight="37dp"
and then try. Are you able to see output on xml graphical layout ? When I tried this on my xml I am able to see in Graphical Layout(I used the same code which you mentioned along with your question).
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world" />
<Button
android:id="#+id/ourButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView"
android:layout_below="#+id/textView"
android:layout_marginRight="37dp"
android:onClick="buttonClick"
android:text="#string/button_string" />
<Button
android:id="#+id/ourButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ourButton"
android:layout_marginLeft="50dp"
android:focusable="false"
android:onClick="buttonClick2"
android:text="#string/button_string2" />
</RelativeLayout>
// try this way
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical"
android:gravity="center"
android:padding="5dp"
tools:context=".MainActivity" >
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<Button
android:id="#+id/ourButton"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:onClick="buttonClick"
android:layout_marginRight="5dp"
android:text="#string/button_string" />
<Button
android:id="#+id/ourButton2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:focusable="false"
android:onClick="buttonClick2"
android:text="#string/button_string2" />
</LinearLayout>
</LinearLayout>

Categories

Resources