提示:这里是收集了和文件分享有关的文章

>>>>可以正常上下滚动,以下是xml布局
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fadeScrollbars="false"
android:scrollbars="vertical">
<!--已开抢-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<!--第1行-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="1dp"
android:paddingRight="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<SeekBar
android:id="@+id/my_seekBar"
style="@style/MySeekBarStyle"
android:layout_width="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:max="2200"
android:minWidth="150dp"
android:progress="10" />
<TextView
android:id="@+id/my_text_view"
android:layout_width="100dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:maxWidth="100dp"
android:minWidth="30dp"
android:textColor="@color/text_white"
android:textSize="16sp" />
</LinearLayout>
<!--分割线-->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#4D000000" />
</LinearLayout>
<!--第2行-->
。。。。。。
<!--第10行-->
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>

>>>>可以正常上下滚动,以下是xml布局
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
app:tabBackground="@drawable/tab_background"
app:tabIndicatorColor="@color/transparent"
app:tabIndicatorHeight="0dp"
app:tabMinWidth="100dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/blue"
app:tabTextColor="@color/white" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
| 依赖库 | 获取值 | 方法 | 结果 |
|---|---|---|---|
| - | File | new File() | /storage/emulated/0/ Android/data/com.bx.share/files/share/xxx.mp3 |
| androidx.core: core:1.5.0 | Uri | FileProvider.getUriForFile(this, authority, file) | content://com.bx.share.fileprovider/external_files/ Android/data/com.bx.share/files/share/xxx.mp3 |
| androidx.core: core:1.6.0 | Uri | FileProvider.getUriForFile(this, authority, file) | content://com.bx.share.fileprovider/files_root/ Android/data/com.bx.share/files/share/xxx.mp3 |
File shareFile = new File(mDirName, mFileName);// /storage/emulated/0/Android/data/com.bx.share/files/
Uri uri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// content://com.bx.share.fileprovider/external_files/Android/data/com.bx.share/files/share/xxx.mp3
uri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", shareFile);
} else {
uri = Uri.fromFile(shareFile);
}
Intent intent = getChooserIntent(uri);
Intent pickIntent = new Intent();
pickIntent.setAction(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_TITLE, "4.分享文件 Pick Activity");
pickIntent.putExtra(Intent.EXTRA_INTENT, intent);
startActivityForResult(pickIntent, RESULT_SHARE);
public Intent getChooserIntent(Uri uri) {
Intent intent = new Intent(Intent.ACTION_SEND);// 共享文件,部分app需要手机联网
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);// 传递权限
intent.putExtra(Intent.EXTRA_TEXT, "分享测试123");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("application/*");// 二进制文件 "application/octet-stream" "*/*"
return intent;
}
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fadeScrollbars="false"
android:scrollbars="vertical">
<!--已开抢-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<!--第1行-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="1dp"
android:paddingRight="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<SeekBar
android:id="@+id/my_seekBar"
style="@style/MySeekBarStyle"
android:layout_width="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:max="2200"
android:minWidth="150dp"
android:progress="10" />
<TextView
android:id="@+id/my_text_view"
android:layout_width="100dp" <!--修改后的-->
android:layout_height="match_parent"
android:editable="false" <!--修改后的-->
android:gravity="center_vertical"
android:maxWidth="100dp"
android:minWidth="30dp"
android:textColor="@color/text_white"
android:textSize="16sp" />
</LinearLayout>
<!--分割线-->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#4D000000" />
</LinearLayout>
<!--第2行-->
。。。。。。
<!--第10行-->
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
提示:这里是参考的相关文章
| 博主分享的所有文章内容,部分参考网上教程,引用大神高论,部分亲身实践,记下笔录,内容可能存在诸多不实之处,还望海涵,本内容仅供学习研究使用,切勿用于商业用途,若您是部分内容的作者,不喜欢此内容被分享出来,可联系博主说明相关情况通知删除,感谢您的理解与支持! |
|---|
转载请注明出处:
https://blog.csdn.net/ljb568838953/article/details/110383353