Set layout height and weight [closed]
I know mobile/tablet height and weight.there is some layout.I give height and we开发者_运维问答idth according to mobile/tablet height and weight .Please help me .I created layout height and weight according to mobile height/weight . Please help me
You can set the layout height and width in layout xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/TitleLayOut"
android:orientation="horizontal"
android:background="#999999">
</LinearLayout
You can even mention the values like "240px" for android:layout_width/android:layout_height
You can do this even in your code something like this
LinearLayout layout= (LinearLayout )findViewById(R.id.TitleLayOut);
android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) layout.getLayoutParams();
lp.width = (getWindowManager().getDefaultDisplay().getWidth()/2);
精彩评论