2011-11-14 61 views
0

我想附加2圖像 第1個在左下角和其他在右下角 但我希望圖像是硬核在底部,這樣,如果我滾動頁面的圖像應保持在同一個地方 感謝如何獲得2圖像附加2佈局botton

+0

發佈您現有的佈局代碼。 –

+0

我想動態地添加我的佈局 –

回答

1

動態,我是成功的回答我的問題,以便即時特此將代碼爲所有用戶和它的作品所以甲肝e代碼並享受

  LinearLayout llMain=new LinearLayout(this); 
     llMain.setOrientation(LinearLayout.VERTICAL); 
     llMain.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); 
     llMain.setBackgroundColor(Color.WHITE); 

     LinearLayout llLsView=new LinearLayout(this); 
     llLsView.setOrientation(LinearLayout.VERTICAL); 
     llLsView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,1.0F)); 
     //llLsView.setPadding(0,0,0,20); 



     LinearLayout llImage=new LinearLayout(this); 
     llImage.setOrientation(LinearLayout.HORIZONTAL); 
     llImage.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
     llImage.setBackgroundColor(Color.BLACK); 

     LinearLayout llHome=new LinearLayout(this); 
     //llHome.setOrientation(LinearLayout.HORIZONTAL); 
     llHome.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.FILL_PARENT,0.5F)); 
     llHome.setPadding(0,0,5,0); 
     llHome.setGravity(Gravity.RIGHT); 

     ImageView imgHome=new ImageView(this); 
     imgHome.setImageResource(R.drawable.home); 
     llHome.addView(imgHome); 

     LinearLayout llBack=new LinearLayout(this); 
     //llBack.setOrientation(LinearLayout.HORIZONTAL); 
     llBack.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.FILL_PARENT,0.5F)); 
     llBack.setPadding(5,0,0,0); 
     llBack.setGravity(Gravity.LEFT); 

     ImageView imgBack=new ImageView(this); 
     imgBack.setImageResource(R.drawable.back); 
     llBack.addView(imgBack); 

     llImage.addView(llBack); 
     llImage.addView(llHome); 

     llMain.addView(llLsView); 
     llMain.addView(llImage); 

     setContentView(llMain); 
+0

+1漂亮精湛的作品! –

0

喜歡的東西:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <ImageView 
     android:id="@+id/nvContent" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/icon" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" /> 

    <ImageView 
     android:id="@+id/nvContent" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/icon" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" /> 

</RelativeLayout> 
+0

我想在java代碼中動態地繪製它 –

+1

@RaghavChopra你應該早些提到,這完全是浪費時間。提問時請小心。 –

+0

將kep dat記在 –

0
<RelativeLayout > 
    <ScrollView > 

    </scrollView> 

    <RelativeLayout android:layout_alighParentBottom=true abdroid:[email protected]/transparnt"> 

    <Button > 
    </Button > 

    <Button android:layout_alighParentRight=true> 
    </Button > 

    <RelativeLayout > 
</RelativeLayout > 
+0

我想動態地繪製cn cn幫我用java代碼 –