想做出下图中球员列表的数字靠右对齐的效果,但。。。菜鸟无能。。。
下图是目前做出的效果,左边数字可以向右对齐,但不知道为什么右边的数字对不起。
我想做出数字垂直中心对齐,而不是整齐向右对齐。。。
这个难题,留着,以后解决
布局文件代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/img1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:id="@+id/mem1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"/>
<TextView
android:id="@+id/sco1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/img2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:id="@+id/mem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"/>
<TextView
android:id="@+id/sco2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
java代码
View view = LayoutInflater.from(context).inflate(R.layout.dialog_item_item,parent,false);
ImageView ivImg1=(ImageView)view.findViewById(R.id.img1);
ivImg1.setImageResource(img[position*2]);
ImageView ivImg2=(ImageView)view.findViewById(R.id.img2);
ivImg2.setImageResource(img[position*2+1]);
TextView tvMen1=(TextView)view.findViewById(R.id.mem1);
tvMen1.setText(memberName[countryNum][position*2]);
//tvMen1.setTextSize(18);
TextView tvMen2=(TextView)view.findViewById(R.id.mem2);
tvMen2.setText(memberName[countryNum][position*2+1]);
//tvMen2.setTextSize(18);
TextView tvSco1=(TextView)view.findViewById(R.id.sco1);
tvSco1.setText(sco[position*2]+"");
tvSco1.setPadding(0, 0, 5, 0);
//tvSco1.setTextSize(18);
TextView tvSco2=(TextView)view.findViewById(R.id.sco2);
tvSco2.setText(sco[position*2+1]+"");
//tvSco2.setTextSize(18);
return view;