2014-11-05 98 views
0

在我的应用我想以这种方式设置的ImageButton的在一个位置安卓:ImageButton的一个动态的大小和位置固定

enter image description here

,我想用这种方式为所有的屏幕适应这个按钮,是有获得它的策略?

+0

你想添加ImageButton的布局有多少?将每个布局的根设置为Relative,并制作一个单独的页脚布局, ImageButton..U需要在每个布局中包含页脚.. :) – TheFlash 2014-11-05 13:17:00

回答

0

这取决于你有多少的屏幕具有应有这个按钮,他们如何相互交流,以及按钮是否应该有相同的基础每个屏幕都有一个离子,但是一个选择是只有一个带有布局的Activity,其中底部有按钮,按钮上方有一个空的布局,作为片段容器。而不是为新的“屏幕”开始新的活动改变这个容器中的碎片。按钮总是在同一个地方,你可以在活动中集中处理它的onClick ...

0

使用

android:align = "Center" 

android:width ="0dp" 
android:weight = "1" 
+0

在大屏幕上没问题,但在小屏幕上,ImageButton非常大!用于小屏幕的 – CrazyDev 2014-11-05 13:21:01

+0

将低像素图像放在具有相同名称的drawable-mdpi文件夹中。 – DJhon 2014-11-05 13:27:24

+0

但在android中可以使用一个图像作为所有设备的项目... – CrazyDev 2014-11-05 13:30:44

0

BPut的ImageView在RelativeLayout并设置ATTRS对于这样的图像视图:

<RelativeLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
     <ImageView 
      android:id="@+id/previewImage" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true"/> 
</RelativeLayout>