Android: Using alignBaseline for an image following text

前端 未结 7 2679
独厮守ぢ
独厮守ぢ 2021-02-13 04:35

Below is a TextView followed by an ImageView contained in RelativeLayout. I\'m trying to get the bottom of the image to align with the baseline of the text. When I use alignBa

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 05:23

    You want to use the android:layout_alignBottom attribute to align the ImageView with the baseline of another View.

    In the sample below I aligned the ImageView to another TextView. I included the code for the ImageView, and not the TextView. In order to align to the TextView you'll just need to include the id of the TextView.

    Adjusting the margin or padding will result in the Views being misaligned if the user changes the text size on their device.

    
    
            
    
            
    
            
    
    
    

提交回复
热议问题