Align ImageView to bottom Right of LinearLayout

前端 未结 4 453
忘掉有多难
忘掉有多难 2021-01-14 01:29

I\'m triying to put an ImageView in bottom right of LinearLayout .... I wrote the code as bellow :

style.xml:



        
相关标签:
4条回答
  • 2021-01-14 01:46

    I would recomend Using RelativeLayout but if you have to useLinearLayout i know that android:scaleType" can help center or move image, did you try android:scaleType="fitEnd" or android:scaleType="fitXY"

    for more Try This

    0 讨论(0)
  • 2021-01-14 01:51

    Use RelativeLayout

        <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="90dp"
                android:background="@drawable/my_background"
                android:layout_alignParentBottom="true"
                 >
    
                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                     android:layout_alignParentRight="true"
                    android:src="@drawable/my_small_image" />
    
                </RelativeLayout>
    
    0 讨论(0)
  • 2021-01-14 02:03

    Using LinearLayout is possible:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:orientation="vertical">
    
        <!-- other elements in linear layout here -->
        <!-- making a RelativeLayout un-desirable -->
    
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="0dp"       
            android:layout_gravity="center"   
            android:layout_weight="1"         
            android:scaleType="fitEnd"        
            android:src="@drawable/your_image" />
    
    </LinearLayout>
    

    This will position the image at the center-bottom, for bottom-right use

    android:layout_gravity="right"
    
    0 讨论(0)
  • 2021-01-14 02:04

    In LinearLayout you can use -

    android:layout_gravity="bottom|right"
    
    0 讨论(0)
提交回复
热议问题