이에 대한 슬라이드 애니메이션을 사용할 수 있습니다. 도움을 위해서 나는 약간의 코드를 추가하고있다. 필요에 따라 수정할 수 있습니다.
다음은 필요한 애니메이션입니다. res 내에서 anim 폴더를 만들고 폴더 안에 애니메이션 애니메이션을 만들고 적절한 이름을 지정하십시오.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.awaheed.testingproject.MainActivity">
<View
android:background="@color/colorAccent"
android:id="@+id/slidder"
android:layout_width="50dp"
android:layout_height="match_parent"
/>
<Button
android:layout_alignParentBottom="true"
android:text="Slide view"
android:id="@+id/btn_slide"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
아래에 언급 그리고 당신을 도와 활동 코드
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final View slideView = findViewById(R.id.slidder);
findViewById(R.id.btn_slide).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Animation animSlide = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.slide);
slideView.startAnimation(animSlide);
}
});
}
희망 아래 사용으로
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="0%p"
android:toXDelta="75%p"
android:duration="800" />
</set>
는 레이아웃 XML을 생성합니다.
네가 한 말대로 했어. 뷰 객체 대신에 선형 레이아웃을 가진 또 다른 .xml 레이아웃 파일을 만들고 레이아웃을 호출하려고했습니다. NullPointerException이 발생했습니다. 어떤 생각 ?? – vinitpradhan18
언제 null 포인터 예외가 발생합니까? 시도한 코드를 게시 할 수 있습니까? –
질문에 코드를 추가했습니다. 나는 당신의 코드를 시험해 보았다. 내가하고 싶은 것은 이미 레이아웃 파일이있는 조각이 있다는 것입니다. 나 자신의 뷰 집합과 함께 조각의 맨 위에 다른 레이아웃 파일을 호출하려고합니다. 내가 어떻게 할 수 있니? 내 조각보기 상단에이보기를 오버레이하고 싶습니다. 또한보기가 왼쪽에서 오른쪽으로 슬라이드됩니다. 내보기를 오른쪽에서 왼쪽으로 슬라이드하려는 경우 (서랍 레이아웃과 비슷 함) – vinitpradhan18