Reputation: 12685
Hi I have this simple Layout
<?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="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_trigger_left"
style="@style/triggerButton"
android:layout_marginRight="5dip"
android:text="Mold" />
<Button
android:id="@+id/btn_trigger_right"
style="@style/triggerButton"
android:text="Fums" />
</LinearLayout>
and style is here.
<style name="triggerButton">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">50dip</item>
<item name="android:textSize">12sp</item>
<item name="android:gravity">center</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/white</item>
<item name="android:layout_weight">2</item>
<item name="android:background">@drawable/symptom_bg</item>
<item name="android:layout_marginBottom">0dip</item>
</style>
and out put is like this.
it is ok, but when My text is long enough to two lines button comes down like this.
please help me when I am doing wrong ? Thanks!
Upvotes: 8
Views: 1071
Reputation: 5391
Put
android:baselineAligned="false"
in your LinearLayout.
LinearLayout aligns the baselines of all its child controls by default and here you need to disable the behaviour.
Upvotes: 11
Reputation: 11359
<item name="android:gravity">center</item>
to
<item name="android:gravity">top</item>
Set gravity in your style.xml
as this. Hope this will help.
Upvotes: 3
Reputation: 10959
Fix maximum length of your text in Button
android:maxLength="20"
Hope this will help.
Upvotes: 0