开发者

Set layout height and weight [closed]

开发者 https://www.devze.com 2023-03-16 17:23 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消