我是一名新的 android 开发人员,我正在尝试为 android 创建一个 android 应用程序,其中将显示菜单项以及描述成本和图像。我已经实现了 List 活动来显示列表中的项目。我制作了一个图像按钮,它将以缩略图的形式显示图像。当我点击图像按钮时,我希望能够查看缩略图的高分辨率图像。我已经实现了一个 onClickListener 来监听点击事件,但我不知道使图像在点击时缩小的方法。
我已经关注了这个链接
但是理解起来很模棱两可。Animator 类不存在。有人可以指导我吗?
我是一名新的 android 开发人员,我正在尝试为 android 创建一个 android 应用程序,其中将显示菜单项以及描述成本和图像。我已经实现了 List 活动来显示列表中的项目。我制作了一个图像按钮,它将以缩略图的形式显示图像。当我点击图像按钮时,我希望能够查看缩略图的高分辨率图像。我已经实现了一个 onClickListener 来监听点击事件,但我不知道使图像在点击时缩小的方法。
我已经关注了这个链接
但是理解起来很模棱两可。Animator 类不存在。有人可以指导我吗?
I found the solution after searching for almost a week.
I used PopupWindow Class for the purpose
Following is the Java Code.
PopupWin.java
public class PopupWin extends Activity{
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            final Button bPopup = (Button)findViewById(R.id.openpopup);
            bPopup.setOnClickListener(new Button.OnClickListener(){
       @Override
       public void onClick(View arg0) {
        LayoutInflater layoutInflater 
         = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);  
        View popupView = layoutInflater.inflate(R.layout.popup, null);  
                 final PopupWindow popupWindow = new PopupWindow(
                   popupView, 
                   LayoutParams.MATCH_PARENT,  
                         LayoutParams.MATCH_PARENT);  
                 Button bDismiss = (Button)popupView.findViewById(R.id.dismiss);
                 bDismiss.setOnClickListener(new Button.OnClickListener(){
         @Override
         public void onClick(View v) {
          // TODO Auto-generated method stub
          popupWindow.dismiss();
         }});
                 popupWindow.showAsDropDown(bPopup, 50, -30);
       }});
        }
    }
popup.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pop"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/dim_back" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/dim_back"
        android:orientation="vertical" >
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:orientation="vertical" 
            android:layout_gravity="center">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:adjustViewBounds="true"
                android:src="@drawable/appetimg01" />
            <Button
                android:id="@+id/dismiss"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="20sp"
                android:text="Go Back"
                android:textStyle="bold" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/appetizerDes1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_weight="0.40"
            android:text="Tap the Image to view High Resolution Image."/>
        <Button
            android:id="@+id/openpopup"
            android:layout_width="80sp"
            android:layout_height="80sp"
            android:layout_gravity="right"
            android:layout_margin="40sp"
            android:background="@drawable/custombutton"
            android:scaleType="centerCrop" />
    </LinearLayout>
</LinearLayout>
The background was appearing white but I wanted it transparent for which I created back_dim.xml in drawables and set it along with android:background="@drawable/back_dim".