3.3在手机屏幕中实现相框效果

java代码

package mars.xiangbu;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;


public class Xiangbu2Activity extends Activity {
    /** Called when the activity is first created. */
private ImageView mImageView01;
private ImageView mImageView02;
private Button mButton01;
private Button mButton02;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        /*获取 对象*/
        mImageView01=(ImageView)findViewById(R.id.myImageView1);
        mImageView02=(ImageView)findViewById(R.id.myImageView2);
        mButton01=(Button)findViewById(R.id.myButton1);
        mButton02=(Button)findViewById(R.id.myButton2);
        /*设置imageview背景图*/
        System.out.println("fuck1");
        mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.right));
        mImageView02.setImageDrawable(getResources().getDrawable(R.drawable.icon));
        System.out.println("fuck");
        mButton01.setOnClickListener(new Button.OnClickListener(){


public void onClick(View v) {
// TODO Auto-generated method stub
mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.right));


}
       
        });
        
        mButton02.setOnClickListener(new Button.OnClickListener(){


public void onClick(View v) {
// TODO Auto-generated method stub
mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.left));


}
       
        });
        
        
        
    }
}


布局文件


<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<ImageView
    android:id="@+id/myImageView1" 
    android:layout_width="320px" 
    android:layout_height="280px" 
    android:layout_x="0px"
    android:layout_y="36px"
    />
 <ImageView
    android:id="@+id/myImageView2" 
    android:layout_width="104px" 
    android:layout_height="157px" 
    android:layout_x="101px"
    android:layout_y="119px"
    />
 <Button 
    android:id="@+id/myButton1"
    android:layout_width="105px" 
    android:layout_height="66px"
    android:text="pic1"
    android:layout_x="9px"
    android:layout_y="356px"
    
    />
 <Button 
    android:id="@+id/myButton2"
    android:layout_width="105px" 
    android:layout_height="66px"
    android:text="pic2"
    android:layout_x="179px"
    android:layout_y="356px"
    />
</AbsoluteLayout>
    当初很奇怪的事:当我把png格式转换为jep格式的图片的时候就能够运行的起来了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值