Ala*_*Lai 5 android layoutparams
我有一个线性布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_menu"
android:layout_width="fill_parent"
android:layout_height="70px"
android:layout_alignParentBottom="true"
android:background="@drawable/footer_bar"
android:gravity="center" >
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当我设定条件
if (constant.getscreenresolution() >= 800) {
//i want to make it height * 2
}
Run Code Online (Sandbox Code Playgroud)
那么如何设定layout params?
Han*_*non 10
用于填充:
LinearLayout mLayout = (LinearLayout)findViewById(R.id.layout_menu);
mLayout.setPadding(left, top, right, bottom);
Run Code Online (Sandbox Code Playgroud)
LinearLayout mLayout = (LinearLayout)v.findViewById(R.id.ll_winfowindo);
int left= (int) activity.getResources().getDimension(R.dimen._18sdp);
int top=(int) activity.getResources().getDimension(R.dimen._22sdp);
int right=(int) activity.getResources().getDimension(R.dimen._18sdp);
int bottom=(int) activity.getResources().getDimension(R.dimen._34sdp);
mLayout.setPadding(left, top, right, bottom);
Run Code Online (Sandbox Code Playgroud)
希望这对你有帮助
LinearLayout.LayoutParams layout_param= new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.fill_parent,
height * 2);
mLayout = (LinearLayout) findViewById(R.id.layout_menu);
mLayout.setLayoutParams(layout_param);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29822 次 |
| 最近记录: |