第一个位置或按钮ill将其设置为无边距,并且后面的位置具有负边距以与第一个位置重叠。
第一个位置没问题,但我在负边距上设置的另一个位置看起来像this。
我想让它像this。
public class ProductLineAdapter extends BaseAdapter{
private List<ProductLineInfo> productLineInfos;
private Context context;
private int prodCount;
public ProductLineAdapter(Context context,
List<ProductLineInfo> productLineInfos) {
this.context = context;
this.productLineInfos = productLineInfos;
prodCount = productLineInfos.size();
Log.d("Tabs", "List Name 1" + prodCount);
}
@Override
public int getCount() {
return productLineInfos.size();
}
@Override
public ProductLineInfo getItem(int position) {
return productLineInfos.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
String name = getItem(position).getName();
int status = productLineInfos.size();
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(
R.layout.productline_name, parent, false);
if (position == 0) {
Button btn = new Button(context);
btn.setText("sample");
btn.setBackgroundDrawable(context.getResources().getDrawable(
R.drawable.tabs_pressed_state));
((ViewGroup) convertView).addView(btn);
convertView.setTag(holder);
} else if (position > 0) {
LinearLayout.LayoutParams layoutParams = new
LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
Button btn1 = new Button(context);
btn1.setText("sample2");
btn1.setBackgroundDrawable(context.getResources().getDrawable(
R.drawable.tabs_pressed_state));
layoutParams.setMargins(-100, 0, 0, 0);
btn1.setLayoutParams(layoutParams);
((ViewGroup) convertView).addView(btn1);
convertView.setTag(holder);
}
} else {
holder = (ViewHolder) convertView.getTag();
}
return convertView;
}
static class ViewHolder {
Button btn;
Button btn1;
}}
答案 0 :(得分:0)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearlayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/blanktab_normal" />
<ImageView
android:id="@+id/b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-60dp"
android:src="@drawable/blanktab_normal" />
<ImageView
android:id="@+id/c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-60dp"
android:src="@drawable/blanktab_normal" />
</LinearLayout>
<ListView
android:layout_below="@id/linearlayout1"
android:layout_height="match_parent"
android:layout_width="match_parent">
</ListView>
</RelativeLayout>