我正在开发一款游戏,用户需要点击ImageView中的图像来旋转它.在每个拍子图像上顺时针旋转90度.但是图像需要时间从旧位置旋转到新位置.这妨碍了游戏体验.我使用了以下内容:
protected void onCreate(Bundle savedInstanceState)
{
...
...
imgview = (ImageView)findViewById(R.id.imageView1);
imgview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Matrix matrix = new Matrix();
matrix.postRotate(90);
Bitmap myImg = getBitmapFromDrawable(imgview.getDrawable());
Bitmap rotated = Bitmap.createBitmap(myImg,0,0,myImg.getWidth(),myImg.getHeight(),matrix,true);
imgview.setImageBitmap(rotated);
}
});
Run Code Online (Sandbox Code Playgroud)
我想知道有没有其他方法旋转图像 而不会产生任何旋转延迟.
我创建了一个允许用户聊天的应用程序.为了显示聊天消息,我使用ListView来显示列表项中的消息.我希望ListView在键盘弹出或关闭时进行相应调整.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<EditText
android:id="@+id/message_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:ems="10"
android:hint="Enter your message..."
android:maxLength="20"
android:paddingLeft="22dp" />
<ImageButton
android:id="@+id/send_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/ok"/>
</RelativeLayout>
<ListView
android:id="@+id/message_listView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:stackFromBottom="true">
</ListView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
每当键盘发生故障时,列表视图应该占据整个屏幕,并且每当用户开始键入时它应该在键盘上方.

谢谢.