如何将2个图像附加到布局底部

时间:2011-11-14 07:23:17

标签: android layout

我想附上2张图片 第一个在左下角,另一个在右下角 但我希望这些图像在底部是硬核,这样如果我滚动页面,图像应该保持在同一个地方

3 个答案:

答案 0 :(得分:1)

动态地,我成功地回答了我自己的问题,所以我特此为所有用户提供代码并且它有效,所以有代码并享受

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

答案 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>

答案 2 :(得分:0)

<RelativeLayout >
   <ScrollView >

   </scrollView>

  <RelativeLayout android:layout_alighParentBottom=true abdroid:backgrond=@color/transparnt">

    <Button >
    </Button >

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

  <RelativeLayout >
</RelativeLayout >