大家好,我已经实施了design library
BottomNavigationView
.它的工作完美,但我不知道为什么我的菜单图标没有显示文字也希望它隐藏,向下滚动,如Floating Action Button
.但我没有找到任何办法.我阅读了Developers Docs,但我找不到任何解决方案.
这是我的输出 - 项目仅显示未启用的文本
预期输出 - 每个项目都应该包含图像和文本
这是我的xml代码
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBackground="@android:color/white"
app:itemIconTint="@drawable/nav_color_state_list"
app:itemTextColor="@drawable/nav_color_state_list"
android:layout_alignParentBottom="true"
app:menu="@menu/bottom_navigation_menu" />
Run Code Online (Sandbox Code Playgroud)
nav_color_state_list.xml可绘制代码
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorAccent" android:state_checked="true" />
<item android:color="@color/textColorSecondary" android:state_checked="false" />
</selector>
Run Code Online (Sandbox Code Playgroud)
bottom_navigation_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_home"
android:title="Home"
android:icon="@drawable/home_black_36dp"
app:showAsAction="ifRoom|withText"/>
<item
android:id="@+id/menu_notification"
android:title="Notifications"
android:icon="@drawable/add_alert_black_36dp"
app:showAsAction="ifRoom|withText"/>
<item
android:id="@+id/menu_call"
android:title="Call"
android:icon="@drawable/comment_black_36dp"
app:showAsAction="ifRoom|withText"/>
<item
android:id="@+id/menu_more"
android:title="More"
android:icon="@drawable/more_horiz_black_36dp"
app:showAsAction="ifRoom|withText"/>>
</menu>
Run Code Online (Sandbox Code Playgroud) 我已经找到了一个让android在webview中工作的方法,但该方法已被弃用.任何人都可以给我新方法的完整代码片段.这是我在这个网站上找到的方法
Java代码如下:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
initiateCall(url);
return true;
}
if (url.startsWith("mailto:")) {
sendEmail(url.substring(7));
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
但是当我将目标平台作为Android 7.1.1时,它无法正常工作
为什么我收到此错误时,我同步Gradle时不会发生,但是当我运行项目时,我收到此错误.
错误:任务':app:transformClassesWithJarMergingForRelease'的执行失败.> com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/common/base/FinalizableReference.class
我不知道哪个依赖项导致此错误,我的依赖项是.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:customtabs:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:percent:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.19.0'
compile 'com.google.android.gms:play-services-auth:11.0.0'
compile 'com.google.android.gms:play-services-location:11.0.0'
compile 'com.google.android.gms:play-services-maps:11.0.0'
compile 'com.google.android.gms:play-services-places:11.0.0'
compile 'com.google.maps.android:android-maps-utils:0.3.4'
compile 'io.nlopez.smartlocation:library:3.3.1'
compile 'com.appeaser.sublimenavigationviewlibrary:sublimenavigationviewlibrary:0.0.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
compile 'com.afollestad:sectioned-recyclerview:0.4.1'
compile 'com.github.medyo:fancybuttons:1.8.3'
compile 'com.basgeekball:awesome-validation:2.0'
compile 'com.github.michaelye.easydialog:easydialog:1.4'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
编辑
我认为播放服务依赖导致了这个问题.当我使用10.2.6
而不是11.0.0
应用程序工作完美时,我只是将dependecies更改为
compile …
Run Code Online (Sandbox Code Playgroud) 我知道之前问过这个问题,但提供的解决方案不足以减少应用程序的大小。
我已经使用react-native init
. 尚未添加任何第三方库。只是一个你好世界的应用程序。但它的发布构建大小是 48mb。
之后我使用def enableProguardInReleaseBuilds = true
它减少了 2Mb,应用程序大小变为 46MB。
我再次使用的def enableSeparateBuildPerCPUArchitecture = true
应用程序大小现在减少了一半,现在是 26MB。
但是为什么只有 react-native 中的 hello world 应用程序需要 26MB。它似乎很没用。
这是我的 package.json 文件
{
"name": "WooVendors",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.5"
},
"devDependencies": {
"@babel/core": "^7.4.4",
"@babel/runtime": "^7.4.4",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.54.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
Run Code Online (Sandbox Code Playgroud) 我有来自服务器的这种价格 html
<del><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">₹</span>12,000.00</span></del> <ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">₹</span>3,999.00</span></ins>
Run Code Online (Sandbox Code Playgroud)
我正在使用 HTMLCompact 在 textview 中呈现它
HtmlCompat.fromHtml(description, HtmlCompat.FROM_HTML_MODE_COMPACT)
Run Code Online (Sandbox Code Playgroud)
但折扣文字不是 StrikeThrough。Del 标签被完全忽略。
根据要求实现代码
<TextView
android:id="@+id/course_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="@font/open_sans_semi_bold"
app:renderHtmlText="@{viewModel.product.priceHtml}"
android:textSize="18sp" />
//Binding Adapter
@BindingAdapter("renderHtmlText")
fun bindRenderHtmlText(view: TextView, description: String?) {
if (description != null) {
view.text = HtmlCompat.fromHtml(description, HtmlCompat.FROM_HTML_MODE_COMPACT)
} else {
view.text = ""
}
}
Run Code Online (Sandbox Code Playgroud) 经过多次轮换并且应用程序处于后台后,我收到此泄漏。这是堆栈跟踪,我无法理解原因。另外32474006字节保留的对象非常多。我有 10 个相同的泄漏。
\n32474006 bytes retained by leaking objects\nDisplaying only 1 leak trace out of 10 with the same signature\nSignature: 329ec5b3be0cfe3ed2fc888129f5a6be93fb9\n\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n\xe2\x94\x82 GC Root: Global variable in native code\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80 android.app.LoadedApk$ServiceDispatcher$DeathMonitor instance\n\xe2\x94\x82 Leaking: UNKNOWN\n\xe2\x94\x82 \xe2\x86\x93 LoadedApk$ServiceDispatcher$DeathMonitor.this$0\n\xe2\x94\x82 ~~~~~~\n\xe2\x94\x9c\xe2\x94\x80 android.app.LoadedApk$ServiceDispatcher instance\n\xe2\x94\x82 Leaking: UNKNOWN\n\xe2\x94\x82 \xe2\x86\x93 LoadedApk$ServiceDispatcher.mContext\n\xe2\x94\x82 ~~~~~~~~\n\xe2\x95\xb0\xe2\x86\x92 com.ics.homework.ui.MainActivity instance\n\xe2\x80\x8b Leaking: YES (ObjectWatcher was watching this because com.ics.homework.ui.MainActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)\n\xe2\x80\x8b key = 8bcc50f8-ea3f-47d9-8dc3-904042a58df4\n\xe2\x80\x8b watchDurationMillis = 60220\n\xe2\x80\x8b retainedDurationMillis = 55216\n====================================\n0 LIBRARY LEAKS\n
Run Code Online (Sandbox Code Playgroud)\n泄漏原因
\n@AndroidEntryPoint\nclass MainActivity : AppCompatActivity(), NavController.OnDestinationChangedListener { …
Run Code Online (Sandbox Code Playgroud) 我尝试创建一个应用程序,其中我必须上传不超过 16-20 mb 的任何文件。我正在使用 OkHttpClient3,但我的主要问题是它将获取具有简单名称的文件,例如 a.mp4、b.jpg 等,但它无法选择像hello world 12.mp4
应该在
RequestBody file_body = RequestBody.create(MediaType.parse(content_type),f).
我的代码中放入什么代码那样的文件。
public void enable_button(){
choosefile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new MaterialFilePicker()
.withActivity(ShowStudent.this)
.withRequestCode(10)
.start();
}
});
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if(requestCode == 100 && (grantResults[0] == PackageManager.PERMISSION_GRANTED)){
enable_button();
}else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},100);
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
if(requestCode …
Run Code Online (Sandbox Code Playgroud) 我在 Android 支持设计折叠工具栏上有一个布局,其中包含 TextView 但是当我折叠我的工具栏时。一些带有工具栏标题的 TextView 显示。我想隐藏所有其他的东西,而不是工具栏和标题。这是我的布局。
<android.support.design.widget.AppBarLayout
android:id="@+id/MyAppbar"
android:layout_width="match_parent"
android:layout_height="256sp"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:background="#ff009688"
app:contentScrim="@color/colorPrimary"
app:expandedTitleMarginTop="100sp"
app:expandedTitleGravity="center|bottom"
android:fitsSystemWindows="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
app:srcCompat="@drawable/bgimg"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/MyToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
<RelativeLayout
android:layout_width="match_parent"
app:layout_anchor="@+id/MyAppbar"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/studentprofile"
app:civ_border_width="2dp"
app:civ_border_color="#0adcf4"
android:layout_marginTop="58dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/branch"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Branch: "
android:textColor="@color/textColorPrimary"
android:textSize="14sp"
android:layout_marginBottom="20sp"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true" />
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
我的Java代码是...
collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.collapse_toolbar);
collapsingToolbar.setTitle(name);
collapsingToolbar.setExpandedTitleTextAppearance(R.style.expandedappbar);
collapsingToolbar.setCollapsedTitleTextAppearance(R.style.collapsedappbar);
final ImageView profile=(ImageView)findViewById(R.id.profile_image);
Picasso.with(this)
.load(photo_url)
.placeholder(R.drawable.studentprofile)
.networkPolicy(NetworkPolicy.NO_CACHE)
.into(new …
Run Code Online (Sandbox Code Playgroud) 今天我已将我的播放服务依赖项升级为compile 'com.google.android.gms:play-services-auth:10.0.1'
.现在我看到setScopes已被弃用.
private GoogleApiClient mGoogleApiClient;
private GoogleSignInOptions gso;
gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(mContext)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
btnGoogleSignIn.s?e?t?S?c?o?p?e?s?(gso.getScopeArray());
Run Code Online (Sandbox Code Playgroud)
现在有什么替代方案.如何设置范围?
android ×8
java ×2
android-collapsingtoolbarlayout ×1
file ×1
leakcanary ×1
react-native ×1
server ×1
upload ×1
web-services ×1