中心向右對齊效果


想做出下圖中球員列表的數字靠右對齊的效果,但。。。菜鳥無能。。。



下圖是目前做出的效果,左邊數字可以向右對齊,但不知道爲什麼右邊的數字對不起。

我想做出數字垂直中心對齊,而不是整齊向右對齊。。。

這個難題,留着,以後解決


佈局文件代碼

<?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;



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章