这是我尝试在snackbar可见时向上推"NEXT"按钮:

如您所见,它无法按计划运行.看起来似乎textview被推到了后面RelativeLayout然后在snackbar消失时重新出现.相反,我想要的是textview出现向上推(因此它在上方snackbar),然后在snackbar消失时再回来.我还创建了一个小的github repo来证明这一点:
https://github.com/Winghin2517/TestFabMotion
这是CoordinatorLayout.Behavior我用于"NEXT"隐藏自己.当snackbar出现时,当它被推高时,行为取自FAB行为:
public class FloatingActionButtonBehavior extends CoordinatorLayout.Behavior<TextView> {
    public FloatingActionButtonBehavior(Context context, AttributeSet attrs) {
    }
    @Override
    public boolean layoutDependsOn(CoordinatorLayout parent, TextView child, View dependency) {
        return dependency instanceof Snackbar.SnackbarLayout;
    }
    @Override
    public boolean onDependentViewChanged(CoordinatorLayout parent, TextView child, View dependency) {
        float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
        child.setTranslationY(translationY);
        return true;
    }
}
我用这个xml试过这个:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" …如果在工具栏中删除了app:layout_scrollFlags值scroll,则内容将移至顶部.见截图
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    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"
    android:fitsSystemWindows="true"
    android:orientation="vertical">
    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical">
        <!--region Content-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
            <!--region EmptyView-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center"
                android:orientation="vertical"
                android:padding="16dp">
                <TextView
                    android:id="@+id/titleView"
                    fontPath="@string/font_semibold"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp"
                    android:gravity="center"
                    android:padding="8dp"
                    android:textColor="#9b9b9b"
                    android:textSize="16sp"
                    tools:ignore="MissingPrefix"
                    tools:text="@string/error_view_internet_connection_title"/>
                <TextView
                    android:id="@+id/messageView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="32dp"
                    android:gravity="center"
                    android:paddingStart="32dp"
                    android:paddingEnd="32dp"
                    android:textColor="#9b9b9b"
                    android:textSize="14sp"
                    tools:ignore="MissingPrefix"
                    tools:text="@string/error_view_internet_connection_message"
                    />
            </LinearLayout>
            <!--endregion-->
            <!--region List-->
            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swipeRefreshLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">
                <RecyclerView
                    android:id="@+id/recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:clipToPadding="false"
                    android:scrollbarSize="2dp"
                    android:scrollbars="vertical"
                    android:visibility="gone"
                    tools:visibility="visible"/> …xml android-layout android-toolbar android-coordinatorlayout
Documents/MyExcelsFolder  我通过使用添加了文件ContentResolver.insert,然后还Documents/MyExcelsFolder通过另一个应用程序将新文件添加到了文件夹(例如FileManager)
MyExcelsFolder然后我尝试从文件夹中获取所有文件
fun getAppFiles(context: Context): List<AppFile> {
        val appFiles = mutableListOf<AppFile>()
        val contentResolver = context.contentResolver
        val columns = mutableListOf(
            MediaStore.Images.Media._ID,
            MediaStore.Images.Media.DATA,
            MediaStore.Images.Media.DATE_ADDED,
            MediaStore.Images.Media.DISPLAY_NAME,
            MediaStore.Images.Media.MIME_TYPE
        ).apply {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                add(
                    MediaStore.MediaColumns.RELATIVE_PATH
                )
            }
        }.toTypedArray()
        val extensions = listOf("xls", "xlsx")
        val mimes = extensions.map { MimeTypeMap.getSingleton().getMimeTypeFromExtension(it) }
        val selection = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            "${MediaStore.MediaColumns.RELATIVE_PATH} LIKE ?"
        } else {
            "${MediaStore.Images.Media.DATA} LIKE ?"
        }
        val selectionArgs = arrayOf(
            "%${Environment.DIRECTORY_DOCUMENTS}/MyExcelsFolder%"
        ) …如何在AlertDialog.Builder AppCompat中更改Items的颜色?
我想将textColor项目(照片,gallary)设置为其他任何项目.
这是我的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
        builder.setTitle(getResources().getString(R.string.choose_image_source));
        builder.setItems(new CharSequence[]{getResources()
                        .getString(R.string.photo), getResources()
                        .getString(R.string.camera)}, new DialogInterface.OnClickListener() {
...
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorAccent">#000000</item><!-- buttons OK cancel-->
        <item name="android:textColorPrimary">#696969</item><!--text in message-->
        <item name="android:background">#f0a400</item> <!-- all bg-->
    </style>
    <style name="MyTitleTextStyle">
        <item name="android:textColor">#000000</item><!-- title color-->
        <item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
    </style>
目前我的SwitchCompat外观如下图(顶部),但是我需要在关闭状态下显示可见文本。
我将如何实现这一目标?

我通过以下方式连接到ble设备:
 mBluetoothGatt = device.connectGatt(this.context, false, mGattCallback);
然后
 mBluetoothGatt.disconnect();
但如果我赶快做,然后我收到status=BluetoothGatt.GATT_FAILURE的onConnectionStateChange的mGattCallback
即使关闭/打开蓝牙,我也无法再次连接到GATT.
只有强制停止应用程序才能解决问题
我在一个 TextView 中使用了两种不同的字体:第一种是 SVG 字体,第二种是 TTF 字体。
要将带有文本的图标设置为 TextView,我正在使用它:
        String icon =getContext().getString(iconId);//""
        String text = getResources().getString(labelId);//"AnyText"
        int iconLength = icon.length();
        String fulltext = icon + " " + text;
        SpannableStringBuilder spLabelWithIcon = new SpannableStringBuilder(fulltext);
        spLabelWithIcon.setSpan(new CustomTypefaceSpan(TypefaceManager.ICONS.getTypeface()),
                0, iconLength, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
        spLabelWithIcon.setSpan(new CustomTypefaceSpan(TypefaceManager.GOTHAM_BOOK.getTypeface()),
                iconLength, fulltext.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
myTextView.setText(spLabelWithIcon);
结果:图标不在行的垂直中心(或者文本不在垂直中心):
我的服务:
public class MusicService extends MediaBrowserServiceCompat {
...
}
我的活动:
public class MediaActivity extends AppCompatActivity{
private MediaBrowserCompat mMediaBrowser;
 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mMediaBrowser = new MediaBrowserCompat(this,
                new ComponentName(this, MusicService.class), mConnectionCallback, null);
        mMediaBrowser.connect();
}
    @Override
    protected void onDestroy() {
        super.onDestroy();
        mMediaBrowser.disconnect();
    }
我想在 UI 中添加关闭按钮,但如何停止MusicService?它继续在后台进行投射。
android android-mediaplayer mediabrowserservice mediabrowserservicecompat mediabrowser
我想按任务顺序创建任务
task fabricUploadDebug(type: Exec) {
dependsOn 'clean'
dependsOn 'compileDebugSources'
dependsOn 'assembleDebug'
dependsOn 'installDebug'
dependsOn 'crashlyticsUploadDistributionDebug'
tasks.getByName('compileDebugSources').mustRunAfter('clean')
tasks.getByName('assembleDebug').mustRunAfter('compileDebugSources')
tasks.getByName('installDebug').mustRunAfter('assembleDebug')
tasks.getByName('crashlyticsUploadDistributionDebug').mustRunAfter('installDebug')}
我正在尝试从右侧面板“ Gradle”运行任务,但是错误是
Gradle sync failed: Task with name 'compileDebugSources' not found in project ':app'. // // Consult IDE log for more details (Help | Show Log) (2s 87ms) (moments ago)
UPDATE 我试图输出所有任务:
 for(item in tasks){
        println "group= "+item.group+" ,path= "+item.path
    }
但是我只有这个:为什么我无法执行其他任务?
group= build ,path= :app:assemble
group= build ,path= :app:assembleAndroidTest
group= build ,path= :app:buildDependents
group= build ,path= :app:buildNeeded …Facebook抛出温暖错误,如何解决?
GraphRequest: Starting with v13 of the SDK, a client token must be embedded in your client code before making Graph API calls. Visit https://developers.facebook.com/docs/android/getting-started#client-token to learn how to implement this change.
我已经添加到清单中了
  <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
版本:
"com.facebook.android:facebook-android-sdk:12.1.0"
android ×9
text ×2
behavior ×1
bluetooth ×1
build.gradle ×1
colors ×1
facebook ×1
file ×1
file-manager ×1
gatt ×1
gradle ×1
mediabrowser ×1
spannable ×1
switchcompat ×1
uri ×1
xml ×1