这是我的代码
ImageButton btnPlayVideo = (ImageButton) findViewById(R.id.btnPlayVideo);
btnPlayVideo.setBackgroundResource(R.drawable.play_icon_grey);
btnPlayVideo.setAdjustViewBounds(true);
btnPlayVideo.setMaxHeight(10);
btnPlayVideo.setMaxWidth(10);
Run Code Online (Sandbox Code Playgroud)
在我的xml中
<ImageButton
android:id="@+id/btnPlayVideo"
android:layout_width="90dp"
android:layout_height="90dp"
android:background="@android:color/transparent"
android:layout_span="2" />
Run Code Online (Sandbox Code Playgroud)
但似乎setmaxheight和layout_height和宽度甚至不起作用.那么如何设置图像按钮的尺寸?
您将需要使用android:scaleType它来调整大小以适应.
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"
android:scaleType="fitXY" />
Run Code Online (Sandbox Code Playgroud)
产生以下输出.

| 归档时间: |
|
| 查看次数: |
20155 次 |
| 最近记录: |