我正在以编程方式进行布局。我的问题是我不能给宽度白色区域?我怎么能这样做。我不能对齐右和中心箭头?
我的代码:
public infoline(Context context) {
super(context);
this.setBackgroundResource(R.drawable.all_line);
new MarginLayoutParams(MarginLayoutParams.FILL_PARENT, MarginLayoutParams.FILL_PARENT);
areaPic=new ImageView(getContext());
areaPic.setBackgroundResource(R.drawable.profil_photo);
mainLayout=new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
mainLayout.setMargins(10,10,10,10);
addView(areaPic, mainLayout);
next=new ImageView(getContext());
next.setBackgroundResource(R.drawable.ok_12_22dip);
LinearLayout.LayoutParams nextlayout =new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
nextlayout.gravity = Gravity.RIGHT;
nextlayout.topMargin=10;
addView(next,nextlayout);
}
的xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="360dip"
android:layout_height="480dip">
<ScrollView
android:layout_height="250dip"
android:layout_width="360dip"
android:id="@+id/scrolline_search">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="200dip"
android:id="@+id/addline_search">
</LinearLayout>
</ScrollView>
</LinearLayout>
答案 0 :(得分:0)
使用此功能可以帮助您
LinearLayout.LayoutParams addQuestion_Params =
new LinearLayout.LayoutParams(100, 100);
这里100是按钮的宽度和高度。