我有一个水平线性布局,有3个视图.打开和关闭按钮和文本视图.加载时,关闭按钮设置为

setVisibility(View.GONE);

所以它只显示一个imageview,open和带有一些文本的textview.我也在用

android:animateLayoutChanges="true"

在我的父布局上,在打开和关闭时为textview设置动画.一切正常,除非我打开/关闭时我可以看到两个按钮的动画分别设置为GONE和VISIBLE.我不想在这两个ImageView上播放动画.关于如何删除这两个视图上的动画的任何想法?提前致谢.

XML文件

android:id="@+id/CuFScrollView"

style="@style/ScrollView"

xmlns:android="http://schemas.android.com/apk/res/android"

android:background="#A0A0A0"

>

style="@style/LinearLayoutVertical"

android:paddingTop="20dp"

>

android:text="Basic Management Plan for Tactical Field Care"

android:id="@+id/header"

style="@style/Header"

/>

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:background="#606060"

android:padding="5dp"

android:animateLayoutChanges="true"

>

android:id="@+id/open"

android:src="@drawable/open"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginRight="5dp"

android:onClick="open"

android:layout_gravity="center_vertical"

android:animateLayoutChanges="false"

/>

android:id="@+id/close"

android:src="@drawable/close"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginRight="5dp"

android:onClick="close"

android:layout_gravity="center_vertical"

android:animateLayoutChanges="false"

/>

android:id="@+id/stepOne"

android:text="Step 1:"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:paddingLeft="0dp"

style="@style/Bullet"

/>

Java文件

import android.os.Bundle;

import android.support.v7.app.AppCompatActivity;

import android.view.View;

import android.widget.ImageView;

import android.widget.ScrollView;

import android.widget.TextView;

public class Careunderfirestudy extends AppCompatActivity{

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

getSupportActionBar().hide();

setContentView(R.layout.careunderfirestudy);

ImageView close = (ImageView)findViewById(R.id.close);

close.setVisibility(View.GONE);

}

public void open(View view){

TextView stepOne = (TextView)findViewById(R.id.stepOne);

stepOne.setText("Casualties should be extricated from burning vehicles or buildings and moved to places of relative safety. Do what is necessary to stop the burning process.");

ImageView close = (ImageView)findViewById(R.id.close);

ImageView open = (ImageView)findViewById(R.id.open);

close.setVisibility(View.VISIBLE);

open.setVisibility(View.GONE);

}

public void close(View view){

TextView stepOne = (TextView)findViewById(R.id.stepOne);

stepOne.setText("Step 1:");

ImageView close = (ImageView)findViewById(R.id.close);

ImageView open = (ImageView)findViewById(R.id.open);

close.setVisibility(View.GONE);

open.setVisibility(View.VISIBLE);

}

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐