相关疑难解决方法(0)

如何在Android中创建虚线/虚线?

我想做一个虚线.我现在正在使用这个实线:

LinearLayout divider = new LinearLayout( this );
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, 2 );
divider.setLayoutParams( params );
divider.setBackgroundColor( getResources().getColor( R.color.grey ) );
Run Code Online (Sandbox Code Playgroud)

我需要这样的东西,但点缀而不是坚实.我想避免在透明布局和实体布局之间交替进行数百种布局.

android

231
推荐指数
10
解决办法
18万
查看次数

当应用程序在真正的Android设备上运行时,虚线实际上没有点缀

在我的应用程序中,我使用XML定义的垂直虚线.

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90"
    android:toDegrees="90">
<shape

    android:shape="line">
    <stroke

        android:width="1dp"
        android:color="@color/light_gray"
        android:dashWidth="2dp"
        android:dashGap="4dp"
        />
</shape>
Run Code Online (Sandbox Code Playgroud)

当我在Android Studio中挑选我的布局时,线条会正确地呈现点状,但是当我在真实设备上运行应用程序时出现问题.这条线很稳固,没有间隙.你知道问题出在哪里吗?我尝试了很多不同的设备,包括那些运行最新4.3 Android的设备.它看起来无处不在:/

android dotted-line xml-drawable android-drawable

28
推荐指数
3
解决办法
8636
查看次数

CardView没有显示阴影高程

我正在使用cardviews,但问题是我的CardView没有显示任何高程或阴影.我已经尝试了一些stackoverflow答案中建议的方法,就像我尝试过使用高程和阴影属性一样.我也尝试过使用card_view:cardUseCompatPadding ="true",但没有任何成功.这是我的xml文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    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="wrap_content"
    xmlns:card_view="http://schemas.android.com/tools"
    android:layout_marginLeft="12dp"
    android:layout_marginRight="12dp"
    android:layout_marginTop="6dp"
    android:layout_marginBottom="6dp"
    app:cardBackgroundColor="#FAFBFD"
    app:cardElevation="5dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/post_profile_image"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:src="@mipmap/ic_launcher"
                android:layout_marginLeft="12dp"
                android:layout_marginTop="12dp"/>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/post_profile_image"
                android:layout_marginLeft="12dp"
                android:orientation="vertical"
                android:layout_marginTop="16dp">

                <TextView
                    android:id="@+id/post_username"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Name"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="#000000"/>

                <TextView
                    android:id="@+id/post_time"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:text="Time"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="@color/grayColor"/>
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true">

                <ImageButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@android:drawable/ic_delete"
                    android:id="@+id/post_delete_btn"
                    android:visibility="invisible"/>

            </LinearLayout>

        </RelativeLayout>

        <ImageView
            android:id="@+id/post_image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="12dp"
            android:adjustViewBounds="true"
            android:background="#00ffffff"
            android:src="@drawable/add_btn"
            android:visibility="gone"/>

        <TextView
            android:id="@+id/post_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

xml android android-cardview

17
推荐指数
7
解决办法
3万
查看次数