相关疑难解决方法(0)

5676
推荐指数
33
解决办法
121万
查看次数

列表视图中的重叠行

如何创建以下视图.

1)使用listview或

2)在scrollview中膨胀自定义视图.这不仅是问题.

如果列表视图然后如何重叠行.

每行都有不同的颜色,来自api webservice.在此输入图像描述

在列表视图中,每行都有我在第二张图片中标记的红色部分的问题.甚至每行背景都不同,相同的颜色将出现在下面的行中.

如何在listview中做纹理效果?

在此输入图像描述

android listview view android-canvas

6
推荐指数
1
解决办法
439
查看次数

Convert Dp to Px in Kotlin - This cast can never succeed

I ran into a problem while coding in Kotlin. I copy-pasted a java code sample that converts DP to Pixels, in order to place it as a parameter for setting padding programatically. I was expecting the IDE to automatically transform it all to Kotlin, however it failed in the process.

The code in Java looks like the following:

float scale = getResources().getDisplayMetrics().density;
int dpAsPixels = (int) (sizeInDp*scale + 0.5f);
Run Code Online (Sandbox Code Playgroud)

After the translation to Kotlin:

val scale = resources.displayMetrics.density
val …
Run Code Online (Sandbox Code Playgroud)

java android kotlin

5
推荐指数
3
解决办法
3772
查看次数

EditText填充无法在Android中按预期方式工作

我在MarshMallow设备上进行了测试。当我写了XML EditText和集PaddingBottomRetype EditText。但它不起作用。但是,当我设置PaddingLeftNew PassWord EditText工作正常。

方法:1

xml代码:

 <EditText
            android:id="@+id/change_password_old_password_edittext"
            android:layout_below="@+id/change_password_mobileNumber_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Old Password"
            android:layout_marginTop="20.0dip"
            android:textColorHint="#40000000"
            android:textSize="@dimen/textsize16"/>

        <EditText
            android:id="@+id/change_password_new_password_edittext"
            android:layout_below="@+id/change_password_old_password_edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="New Password"
            android:layout_marginTop="20.0dip"
            android:textColorHint="#40000000"
            android:paddingLeft="10dip"
            android:textSize="@dimen/textsize16"/>

        <EditText
            android:id="@+id/change_password_retype_password_edittext"
            android:layout_below="@+id/change_password_new_password_edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Retype Password"
            android:layout_marginTop="20.0dip"
            android:paddingBottom="10dip"
            android:textColorHint="#40000000"
            android:textSize="@dimen/textsize16"/>
Run Code Online (Sandbox Code Playgroud)

屏幕截图:

在此处输入图片说明

方式:2

然后,我决定以PaddingBottom编程方式进行设置。但是它给出了奇怪的输出。

Java代码:

内部OnCreate方法

   EditText change_password_retype_password_edittext = (EditText)findViewById(R.id.change_password_retype_password_edittext);
        change_password_retype_password_edittext.setPadding(0,0,0,10);
Run Code Online (Sandbox Code Playgroud)

输出:

在此处输入图片说明

注: 我已经测试上MarshmallowLolliPopJellybean。但是在所有设备上都无法正常工作。

xml android android-layout android-edittext android-studio

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