我正在使用动画显示/隐藏我的按钮。我做到了,但我遇到了严重的问题。
当我隐藏第一个按钮,然后我隐藏第二个按钮时,我可以看到第一个按钮显示然后隐藏得那么快。我尝试了一切。
显示按钮:
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true"><scale
android:duration="450"
android:fromXScale="0.0"
android:fromYScale="0.0"
android:toXScale="1.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
/></set>
隐藏按钮:
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true"><scale
android:duration="300"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="0.0"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
/></set>
Java:
public class MainActivity extends AppCompatActivity {
Button btn1,btn2,btn3;
Animation show , hide;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1 = (Button)findViewById(R.id.btn1);
btn2 = (Button)findViewById(R.id.btn2);
btn3 = (Button)findViewById(R.id.btn3);
show = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.Show);
hide = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.Hide);
}
public void setBtn1(View v) {
btn1.startAnimation(hide);
btn1.setClickable(false);
}
public void setBtn2(View v) {
btn2.startAnimation(hide);
btn2.setClickable(false);
}
public void setBtn3(View v) {
btn3.startAnimation(hide);
btn3.setClickable(false);
}
这是activity_main.xml:
<android.support.constraint.ConstraintLayout 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=".MainActivity" >
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="setBtn1"
android:text="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/btn3"
android:layout_marginStart="3dp"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="65dp"
app:layout_constraintLeft_toRightOf="@+id/btn2"
android:layout_marginLeft="3dp" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:onClick="setBtn2"
android:text="2"
android:layout_marginStart="57dp"
app:layout_constraintBaseline_toBaselineOf="@+id/btn3"
tools:layout_constraintBaseline_creator="1"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="57dp" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:onClick="setBtn3"
android:text="3"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="71dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="191dp"
android:layout_marginRight="71dp" />
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
您需要从隐藏文件和Show.xml文件中删除select p.productid, p.productname, p.categoryid, p.unitprice
from (select p.*,
row_number() over (partition by p.categoryid order by p.price asc) as seqnum
from production.products p
) p
where seqnum = 1
order by p.categoryid;
。
请将文件重命名为hide.xml和show.xml,(这是Java代码汇编)
并使用我的MainActivity.java实现
android:fillAfter="true"