以下是代码manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testmove"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="7" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.testmove.MainActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application></manifest>-----------------------------------------------------------------------------------------------------------------------------------------------------------------
activity_main:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageButton
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher"/>
<Button
android:id="@+id/move"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="move"
android:layout_alignParentBottom="true"
></Button></RelativeLayout>
----------------------------------------------------------------------------------------------------------------------------------------------------
MainActivity.java:public class MainActivity extends Activity implements OnClickListener
{ @Override
protected void onCreate(Bundle savedInstanceState)
{
Log.v("debug", "create");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn=(Button)findViewById(R.id.move);
btn.setOnClickListener(this);
RelativeLayout.LayoutParams mParams=new RelativeLayout.LayoutParams(50,30);
ImageButton tView=(ImageButton)findViewById(R.id.image);
tView.setLayoutParams(mParams);
} @Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
if(v.getId()==R.id.move)
{
ImageButton tView=(ImageButton)findViewById(R.id.image);
tView.layout(tView.getLeft()-30, tView.getTop()+30, tView.getRight()-30, tView.getBottom()+30);
}
}
@Override
public void onConfigurationChanged(Configuration newConfig)
{
// TODO Auto-generated method stub
Log.v("debug", "config change");
super.onConfigurationChanged(newConfig);
}}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testmove"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="7" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.testmove.MainActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application></manifest>-----------------------------------------------------------------------------------------------------------------------------------------------------------------
activity_main:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageButton
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher"/>
<Button
android:id="@+id/move"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="move"
android:layout_alignParentBottom="true"
></Button></RelativeLayout>
----------------------------------------------------------------------------------------------------------------------------------------------------
MainActivity.java:public class MainActivity extends Activity implements OnClickListener
{ @Override
protected void onCreate(Bundle savedInstanceState)
{
Log.v("debug", "create");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn=(Button)findViewById(R.id.move);
btn.setOnClickListener(this);
RelativeLayout.LayoutParams mParams=new RelativeLayout.LayoutParams(50,30);
ImageButton tView=(ImageButton)findViewById(R.id.image);
tView.setLayoutParams(mParams);
} @Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
if(v.getId()==R.id.move)
{
ImageButton tView=(ImageButton)findViewById(R.id.image);
tView.layout(tView.getLeft()-30, tView.getTop()+30, tView.getRight()-30, tView.getBottom()+30);
}
}
@Override
public void onConfigurationChanged(Configuration newConfig)
{
// TODO Auto-generated method stub
Log.v("debug", "config change");
super.onConfigurationChanged(newConfig);
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货