Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I writed this like,.. I have a layout problem. I cant fill screen with two buttons. parentlayout fills screen, but I cant these two buttons put should be..</p> <p><img src="https://i.stack.imgur.com/OZkWA.png" alt="enter image description here"></p> <p>My button layout:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:gravity="center"&gt; &lt;ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/xbutton2_icon" /&gt; &lt;TextView android:id="@+id/xbutton2_tv" android:layout_height="wrap_content" android:layout_width="wrap_content" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And its class:</p> <pre><code>public XButton2(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.xbutton2, this); icon = (ImageView) view.findViewById(R.id.xbutton2_icon); tv = (TextView) view.findViewById(R.id.xbutton2_tv); init(attrs); } protected void init(AttributeSet attrs) { parseAttributes(attrs); setAttrs(); } protected void parseAttributes(AttributeSet attrs) { TypedArray param = getContext().obtainStyledAttributes(attrs, R.styleable.com_matriksdata_bavul_XButton2); this.text = param .getString(R.styleable.com_matriksdata_bavul_XButton2_text); String str = param .getString(R.styleable.com_matriksdata_bavul_XButton2_icon); if (str != null) { String[] arr = str.split("\\/"); this.iconResorucesID = getResources().getIdentifier( getContext().getApplicationContext().getPackageName() + ":" + arr[arr.length - 2] + "/" + arr[arr.length - 1].split("\\.")[0], null, null); } this.textSize = param.getFloat( R.styleable.com_matriksdata_bavul_XButton2_textSize, 40); param.recycle(); } protected void setAttrs() { if (text != null) { tv.setText(text); tv.setTextSize(XUtil.convertToPixcell(getContext(), textSize)); // tv.setTextColor(textColor); // tv.setHighlightColor(textSelectedColor); } if (iconResorucesID != 0) icon.setImageResource(iconResorucesID); } public void setChecked(boolean isChecked) { if (isChecked) { // setBackgroundResource(selectedBg); tv.setSelected(true); } else { tv.setSelected(false); // setBackgroundResource(bg); } this.isChecked = isChecked; } </code></pre> <p>And it is where I used it.</p> <pre><code>&lt;com.matriksdata.widget.SplitButtonController android:layout_marginLeft="8dip" android:layout_marginRight="8dip" android:layout_width="fill_parent" android:orientation="horizontal" android:layout_height="wrap_content" android:gravity="center_vertical" &gt; &lt;com.matriksdata.widget.XButton2 mtx:text="@string/strFlight" mtx:textSize="20" mtx:icon="@drawable/flight_buttonicon" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/&gt; &lt;com.matriksdata.widget.XButton2 mtx:text="@string/strBus" mtx:textSize="20" mtx:icon="@drawable/bus_buttonicon_gray" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" /&gt; &lt;/com.matriksdata.widget.SplitButtonController&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload