У меня есть следующий код в макете xml. Я хотел бы, чтобы фаб исчезал после того, как пользователь щелкнул по нему, и снова появился после действий, указанных в sendData()
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="org.toto.test.RecordAction">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="37dp"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#40f4b8"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_record_action" />
<ImageView
android:id="@+id/imageView"
android:layout_marginTop="35dp"
android:layout_width="match_parent"
android:layout_height="567dp"
app:srcCompat="@drawable/sahasrakshi"
tools:layout_editor_absoluteY="0dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/colorPrimary"
app:srcCompat="@drawable/ic_send_white_18dp" />
</android.support.design.widget.CoordinatorLayout>
И пытаюсь изменить потрясающую видимость. Это не работает. Код для звонка есть
CoordinatorLayout.LayoutParams p = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
p.setAnchorId(View.NO_ID);
fab.setLayoutParams(p);
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (checkValidation())
//fab.setBackgroundColor(Color.parseColor("#ffffff"));
//fab.hide();
fab.setVisibility(View.INVISIBLE);
sendData();
//fab.setBackgroundColor(Color.parseColor("#e7ffcc"));
//fab.show();
//fab.setEnabled(true);
fab.setVisibility(View.VISIBLE);
}
});
Пытался изменить цвет, использовал show() и hide() и не смог этого сделать. Может ли кто-нибудь помочь мне, пожалуйста?
Adding sendData()
protected void sendData() {
amtInWords = convertNumberToWords(Amount);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.SEND_SMS)) {
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.SEND_SMS},
MY_PERMISSIONS_REQUEST_SEND_SMS);
}
} else {
sendSMS();
}
getDeviceName();
editInvisibleFocusHolder.setInputType(InputType.TYPE_NULL);
editInvisibleFocusHolder.requestFocus();
captureScreen();
sendEmail();
onFabVisible(true);
quit();
}
}