Issue
in my android actionbar i have 2 custom buttons ill post the code below but my problem is the buttons get stretched in the actionbar how do i set it to fit the text and not strech?? here is my code for
activity_main_ab.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="fill_horizontal"
android:orientation="horizontal" >
<LinearLayout
android:layout_alignParentLeft="true"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/action_bar_button_about"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ios_btn"
android:text="about" />
<Button
android:id="@+id/action_bar_button_reload"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/ios_btn"
android:layout_weight="1"
android:text="reload" />
</LinearLayout>
</RelativeLayout>
and MainActivity.java
package jb.cydia;
import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ActionBar ab = getActionBar();
ab.setDisplayShowHomeEnabled(false);
ab.setDisplayShowTitleEnabled(false);
final LayoutInflater inflater = (LayoutInflater)getSystemService("layout_inflater");
View view = inflater.inflate(R.layout.activity_main_ab,null);
ab.setCustomView(view);
ab.setDisplayShowCustomEnabled(true);
}
}
Oh almost forgot it is android even tho it looks like the screenshot was from ios .. i rooted my phone to look like that :) androids about customization right?
Solution
<Button
android:layout_width="fill_parent"
... />
Should be
<Button
android:layout_width="wrap_content"
... />
Answered By - Adam S
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.