android - LinearLayout problem -


I'm facing a problem to customize linear layout. My XML is as follows:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; RelativeLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Orientation = "Horizontal" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: background = "#ffffff "& Gt; & Lt; LinearLayout Android: id = "@ + id / linearLayout_LeftPanel" Android: layout_width = "wrap_content" Android: layout_height = "fill_parent" Android: background = "# 0000ff" & gt; & Lt; TextView android: id = "@ + id / leftPanel_Title" Android: Android: "Frequently Asked Questions" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: textColor = "# 000000" /> & Lt; / LinearLayout & gt; & Lt; LinearLayout Android: id = "@ + id / linearLayout_MainContent" android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: gravity = "center" Android: layout_toRightOf = "@ + id / linearLayout_LeftPanel" & gt; & Lt; TextView Android: Android: Android: Android: Android: Android: Android: Text Code = Android: Android: Android: Android: Text: Android: Android: Android: Text: Android: Android: Android: Text: Android: Android: Text: "Alabama Rule of the Sepoy Process" = "19px" Android: Textstyle = "bold" /> & Lt; / LinearLayout & gt; & Lt; / RelativeLayout & gt;  

I want to set a quarter width of + quarter / liner layout / left panel label on pro-grammatically on-craylet width. So how can it be?

The answer from Mina Sammy is almost perfect, but you are one of your most containers as RelativeLayout Android: Layout_weight The feature works only when the surrounding containers are a linear target:

   
  create a protected zeros (bundle B) {LinearLayout leftPanel = ( LinearLayout) findViewById (R.id.LeftPanel); LinearLayout.LayoutParams leftPanelParams = (LinearLayout.LayoutParams) leftPanel.getLayoutParams (); LeftPanelParams.weight = 1; // do the same thing for main content, but set the weight to 3; }  

Comments