Aya*_*avi 0 android android-layout
我有我的屏幕的XML结构.我希望我的相对布局与id journeyLandingView在点击某个按钮时向上滑动并显示具有id journeyRootView的视图RelativeLayout,它将从底部向上滑动,因为journeyLandingView将Fill_Parent设置为高度和宽度,因此journeyRootView必须低于journeyLandingView覆盖整个屏幕.我怎样才能做到这一点?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/journeyLandingView">
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/journeyRootView"
android:background="@drawable/root_layer">
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
小智 7
我相信你想要的动画类型可以使用ViewFlipper实现.
您可以将RelativeLayouts放入ViewFlipper,并以编程方式在ViewFlipper上设置输入和输出动画.
示例代码:
xml(布局):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="click me"
android:id="@+id/btn"
/>
<ViewFlipper
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/viewFlipper"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/journeyLandingView"
android:background="#FFFFFF"
>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/journeyRootView"
android:background="#FFA500"
>
</RelativeLayout>
</ViewFlipper>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
java(活动):
ViewFlipper vflipper;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vflipper = (ViewFlipper) findViewById(R.id.viewFlipper);
vflipper.setInAnimation(this, android.R.anim.slide_in_left);
vflipper.setOutAnimation(this, android.R.anim.slide_out_right);
Button btn = (Button) findViewById(R.id.btn);
btn.setOnClickListener(this);
}
public void onClick(View v)
{
vflipper.showNext();
}
Run Code Online (Sandbox Code Playgroud)
您将使用自定义动画而不是我在示例代码中使用的"android.R.anim.slide_in_left"和"android.R.anim.slide_out_right":
vflipper.setInAnimation(this, android.R.anim.slide_in_left);
vflipper.setOutAnimation(this, android.R.anim.slide_out_right);
Run Code Online (Sandbox Code Playgroud)
但是,我并不擅长制作自定义动画,所以我将它留给自己.真的希望这有帮助:-)
| 归档时间: |
|
| 查看次数: |
5277 次 |
| 最近记录: |