小编Che*_*eng的帖子

在ScrollView android内部切断了CardView底部边框

我将cardview放在scrollview中,我们希望看到底部应该显示边框(见下图).但事实并非如此.问题是我无法滚动到底部以查看cardview的边框.

SO上的所有解决方案都是将layout_margins更改为paddings,但如果我们想要显示边框,则不是cardview的情况.我基本上尝试了一切.但仍然无法奏效. 滚动到底部无法看到边框

图片1.滚动到底部无法看到边框

我们可以看到顶部边界

图2.我们可以看到顶部边框

以下是xml代码

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true">

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp">
                    <LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="vertical"
                      >
                     ...
                    </LinearLayout>
           </CardView>
  </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

参考: ScrollView不会滚动到底部

ScrollView会切掉顶部并在底部留出空间

我无法在底部显示LinearLayout以滚动视图

Android ScrollView拒绝滚动到底部

android scrollview cardview

16
推荐指数
3
解决办法
7680
查看次数

使用<merge标签android无法使用margin或padding

我在自定义视图中使用合并标记,并尝试在父视图上设置layout_marginTop或paddingTop,但不起作用.这是我的代码文件名:my_view.xml

<merge
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android_layout_marginTop="17dp" >  // This margin is lost!
    // content here  ...
</merge>
Run Code Online (Sandbox Code Playgroud)

所以在我的自定义视图文件MyView.java中,我只是给这个my_view.xml充气.但是android_layout_marginTop信息丢失了.

public class MyView {
    private void initViews() {
        View view = LayoutInflator.from(context).inflate(R.layout.my_view, this);
        // get rest views
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图使用LayoutParams在代码中设置边距和填充,但仍然无法正常工作.非常感谢您的帮助!

xml android

4
推荐指数
1
解决办法
1470
查看次数

Robolectric测试找不到字体文件

我现在花了几天时间,但仍然无法找到解决方案.我在运行robolectric测试时遇到错误,表示无法找到字体文件.以下是整个堆栈跟踪

android.view.InflateException: XML file build/intermediates/res/merged/debug/layout/fragment_users_list.xml line #-1 (sorry, not yet implemented): Error inflating class com. mycustom.common.views.RobotoTextView

// real issue here
Caused by: java.lang.RuntimeException: Font not found at [build/intermediates/bundles/debug/assets/Roboto-Light.ttf]
at org.robolectric.shadows.ShadowTypeface.createFromAsset(ShadowTypeface.java:73)
at android.graphics.Typeface.createFromAsset(Typeface.java)
at com.mycustom.utils.font.RobotoUtil.getRobotoTypeface(RobotoUtil.java:45)
at com.mycustom.common.views.RobotoTextView.setFontType(RobotoTextView.java:46)
at com.mycustom.common.views.RobotoTextView.<init>(RobotoTextView.java:33)
... 89 more
Run Code Online (Sandbox Code Playgroud)

基本上我有使用自定义字体文件的xml文件,字体文件保存在res文件夹中,当我在Robolectric测试中升级活动实例,并且活动初始化时,它将在/ build/intermediates/res中查找字体文件/ merged文件夹,但不知何故,robolectric找不到该字体文件.

不知道为什么会这样.任何建议将不胜感激!

robolectric

3
推荐指数
1
解决办法
759
查看次数

标签 统计

android ×2

cardview ×1

robolectric ×1

scrollview ×1

xml ×1