gpt4 book ai didi

android - 防止 ImageButton 进入后台

转载 作者:太空狗 更新时间:2023-10-29 16:39:17 24 4
gpt4 key购买 nike

这是我要旋转的 Android ImageButton。

Button partially hidden on rotation

它确实会旋转,但正如您从屏幕截图中看到的那样,它的一部分在旋转过程中进入了背景/不可见状态。如何确保 ImageButton 在整个旋转过程中保持完全可见?

这是 Activity 代码:

public class MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageButton imgbt = (ImageButton)findViewById(R.id.mybutton);

RotateAnimation ra =new RotateAnimation(0, 360);
ra.setFillAfter(true);
ra.setDuration(2000);
imgbt.startAnimation(ra);
}
}

还有 XML:

<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >

<ImageButton
android:id="@+id/mybutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/mybutton" />
</LinearLayout>

最佳答案

在你的 LinearLayout 中,改变这个:

android:layout_height="wrap_content"

为此:

android:layout_height="match_parent"

因此,您将确保容器足够大以完整显示图像按钮,即使它是垂直的。

关于android - 防止 ImageButton 进入后台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20854255/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com