@Override
public void onResume() {
super.onResume();
recyclerView.post(new Runnable() {
@Override
public void run() {
((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(position, viewTopDistance);
}
});
}
Run Code Online (Sandbox Code Playgroud)
当用户单击启动另一个活动的视图时,位置和 viewTopDistance 会正确保存和保留。返回回收器视图后,大约 2/3 的时间列表看起来正确,另外 1/3 的时间它仅在顶部显示前 4 或 5 次(scrollToPositionWithOffset 不起作用)
关于为什么有时会失败的任何想法?
我正在使用这个材料设计导航抽屉的示例,问题是,当我打开抽屉时,它也覆盖了我的操作栏..并且我的抽屉图标不可见..这就是我得到的..下面是我的代码..
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
<FrameLayout
android:id="@+id/container_body"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:name="info.androidhive.materialdesign.activity.FragmentDrawer"
android:layout_width="@dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我正在尝试创建一个可折叠的 div 来保存图像的缩略图。到目前为止,除了 div 内容(缩略图)在折叠和展开时闪烁并消失之外,一切正常。内容就在那里,只是没有留下来。如果您足够快,您可以在缩略图闪烁时单击它,它会将您带到图像路径。我的 div 看起来像这样:
<div class="col-lg-8 col-lg-offset-2">
<div id="images" class="accordion-body collapse">
<a href="../images/1953.01.09.00.jpg" class="thumbnail">
<img src="../images/1953.01.09.00.jpg">
</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
还有我的按钮:
<a class="btn accordion-toggle" data-toggle="collapse" href="#images">Images »</a>
Run Code Online (Sandbox Code Playgroud)
您可以在这里查看我的完整代码:https ://jsfiddle.net/krbylit/jttyq8jv/
我想显示文本后跟一个图标。
我正在使用材质图标。
我想实现左边的目标。但右边是我得到的。
我尝试了填充、边距、行高等一切,但无法使它们对齐。
上述问题的工作网页在这里
网页
<div class="package-rating-detail">
<label>{{package.rating}}</label>
<mdl-icon class="mdl-color-text--orange">star_rate</mdl-icon>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.package-rating-detail {
float: left;
margin-left: 20px;
}
Run Code Online (Sandbox Code Playgroud)
那么如何对齐标签和图标呢?
我遇到了一个问题 Slider (Seekbar) 在 Android 上对我不起作用。我收到此错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tutorme, PID: 16570
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tutorme/com.example.tutorme.activities.FilterTutorActivity}: android.view.InflateException: Binary XML file line #26 in com.example.tutorme:layout/activity_filter_tutor: Binary XML file line #60 in com.example.tutorme:layout/content_filter_tutor: Error inflating class com.google.android.material.slider.Slider
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: android.view.InflateException: Binary XML file line #26 in com.example.tutorme:layout/activity_filter_tutor: Binary XML file line #60 in …Run Code Online (Sandbox Code Playgroud) 我正在尝试在表格组件的每一行之间创建空间。我在 TableRow、TableCell、TableBody 和 Table 上使用了类名和类属性,但没有任何效果。我也尝试创建自定义主题,但它也不起作用。这是代码,
const useStyles = makeStyles({
table: {
minWidth: 650
},
tableRow: {
cursor: "pointer",
borderLeft: "8px solid #9a031e",
marginTop: "8px"
},
tableCell: {
marginTop: "8px"
}
});
function createData(name, calories, fat, carbs, protein) {
return { name, calories, fat, carbs, protein };
}
const rows = [
createData("Frozen yoghurt", 159, 6.0, 24, 4.0),
createData("Ice cream sandwich", 237, 9.0, 37, 4.3),
createData("Eclair", 262, 16.0, 24, 6.0),
createData("Cupcake", 305, 3.7, 67, 4.3),
createData("Gingerbread", 356, 16.0, 49, 3.9)
]; …Run Code Online (Sandbox Code Playgroud) 我正在努力为项目中的按钮设置正确的样式。我不知道为什么shapeAppearance不工作。即使我只使用cornerSize它也不起作用。
我有一个按钮的基本样式:
<style name="SnButton" parent="Widget.MaterialComponents.Button.UnelevatedButton">
<item name="shapeAppearance">@style/MyShapeAppearance</item>
<item name="backgroundTint">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是我的按钮形状外观:
<style name="MyShapeAppearance" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">2dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是我的基本主题:Theme.MaterialComponents.Light.NoActionBar.Bridge
在我的情况下,我应该怎么做才能强制shapeAppearance工作?或者至少cornerSize?
我是 jetpack compose 的新手,我一直在尝试覆盖应用程序中的背景和表面颜色以查看效果,但它仅适用于我的 api 30 及以下虚拟设备,但在我的物理设备(即 api 31)上没有任何作用以及 API 30 以上的其他虚拟设备,我使用的是material3
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80,
surface = Color(0XFF0C134F),
background = Color(0XFF0C134F),
onSurface = Color(0xffffffff)
)
private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40,
surface = Color(0XFFB6EAFA),
background = Color(0XFFB6EAFA),
/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F), …Run Code Online (Sandbox Code Playgroud) 我在我的活动中包含了导航抽屉,我需要动态更改导航标题窗口小部件(图像视图,文本视图)值,如加载应用用户名,个人资料图片和手机号码.所以请帮我这样做.提前致谢.

我想创建一个这样的简单视图.(红圈)
我在互联网上搜索了Recyclerview中的Bundling但我找不到任何资源.
任何人都可以告诉我这个视图的名称或分享任何教程资源.
有人可以分享如何做到这一点的例子.或任何关于如何获得此视图的教程. - 赏金问题
material-design ×10
android ×6
css ×2
kotlin ×2
material-components-android ×2
angular2-mdl ×1
html ×1
java ×1
material-ui ×1
reactjs ×1