小编Rah*_*rma的帖子

触摸基线的TextInputLayout中显示密码图标

我在TextInputLayout中使用show password图标时遇到了一些问题android:inputType="textPassword".现在它显示这样在此输入图像描述

如您所见,显示密码图标正在触及基线.我想要这样的东西在此输入图像描述

你可以看到他们之间的差距.

用于实现TextInputLayout的xml sode如下:

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/TextLabelSNA"
    app:layout_constraintTop_toBottomOf="@+id/mailSave"
    app:layout_constraintBottom_toBottomOf="parent"
    android:layout_marginBottom="16dp"
    android:layout_marginTop="16dp"
    android:layout_marginStart="16dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginLeft="16dp"
    android:layout_marginEnd="16dp"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginRight="16dp"
    android:id="@+id/tilOp"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintVertical_bias="0.0">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:inputType="textPassword"
        android:hint="Old Password"
        android:ems="10"
        android:textColor="#0A0B12"
        android:id="@+id/oldPassword"/>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

使用的风格是:

<style name="TextLabelSNA" parent="Widget.Design.TextInputLayout">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@color/hintBlack</item>
    <item name="android:textSize">16sp</item>
    <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
    <item name="colorAccent">@color/hintBlack</item>
    <item name="colorControlNormal">@color/hintBlack</item>
    <item name="colorControlActivated">@color/hintBlack</item>
</style>
Run Code Online (Sandbox Code Playgroud)

请帮忙..!!!

android material-design

8
推荐指数
3
解决办法
2万
查看次数

设置适配器时如何避免让android spinner调用itemselectedlistener?

似乎android的Spinner类(一般可能是ListView,虽然我不确定)onItemSelected()在你调用之后调用你的OnItemSelectedListener的方法setAdapter(),即使用户还没有明确选择任何东西.

我可以看到这在许多情况下如何有用,但有时我只想onItemSelected()在实际特别选择项目时调用它.

有没有办法控制此行为并onItemSelected()在设置适配器后调用Spinner ?

android android-spinner

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

更新Google支持库后,TextInputLayout提示不会浮动

我最近更新了我的支持库,com.android.support:appcompat-v7:25.1.0之后如果我将文本添加到EditTextvia xml文件中,则TextInputLayout提示不会浮动.

我也看过这个问题,但它对我不起作用.

这是我的xml代码:

<android.support.design.widget.TextInputLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginRight="16dp"
        app:layout_constraintVertical_bias="0.0"
        android:id="@+id/til1"
        android:layout_marginStart="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="16dp"
        app:layout_constraintHorizontal_bias="0.33">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="From"
            android:inputType="time"
            android:text="09:00 AM"
            android:id="@+id/from_mon"
            android:textSize="14sp" />
    </android.support.design.widget.TextInputLayout> 
Run Code Online (Sandbox Code Playgroud)

这是我的gradle依赖项:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.android.support:recyclerview-v7:25.1.0'
    compile 'com.android.support:cardview-v7:25.1.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.github.bhargavms:DotLoader:1.0.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.labo.kaji:fragmentanimations:0.1.1'
    compile …
Run Code Online (Sandbox Code Playgroud)

android android-support-library android-textinputlayout

7
推荐指数
2
解决办法
3022
查看次数

从子textInputEditText获取父texInputlayout

我正在实现一个功能,当提示浮动时将textInputlayout提示文本的大小写更改为大写,反之亦然.

为此,我正在使用OnFocusChangeListener它的孩子textInputEditText.为了便于实现,我正在实施View.OnFocusChangeListener我的活动,如:

public class LoginActivity extends BaseActivity implements View.OnFocusChangeListener
Run Code Online (Sandbox Code Playgroud)

并覆盖活动中的方法,如:

@Override
public void onFocusChange(View v, boolean hasFocus) {
    if(findViewById(v.getId()) instanceof TextInputEditText){
        TextInputLayout textInputLayout = (TextInputLayout) findViewById(v.getId()).getParent();
        if(hasFocus){
            textInputLayout.setHint(textInputLayout.getHint().toString().toUpperCase());
        }else{
            textInputLayout.setHint(Utility.modifiedLowerCase(textInputLayout.getHint().toString()));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在上面的方法中,我试图textInputLayout使用该行获取父视图

TextInputLayout textInputLayout = (TextInputLayout) findViewById(v.getId()).getParent();
Run Code Online (Sandbox Code Playgroud)

上面的代码行引发致命错误

java.lang.ClassCastException:android.widget.FrameLayout无法强制转换为android.support.design.widget.TextInputLayout

它非常明显,因为它返回了Framelayout无法投入的内容textInputLayout

如果我使用

TextInputLayout textInputLayout = (TextInputLayout) findViewById(v.getId()).getRootView();
Run Code Online (Sandbox Code Playgroud)

它再次抛出一个致命的错误,因为无法投入的getRootView()回报DecorViewtextInputLayout

我的问题是如何textInputLayout从孩子那里得到父母textInputEditText

请指导.

android android-design-library android-textinputlayout android-textinputedittext

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

将后缀添加到 WiFi Direct 组名称的名称中。(类似于 PDANet 的做法)

我正在尝试创建一个具有自定义名称的 WiFi Direct 组。但在探索了所有选项之后,我发现我们无法更改名称,并且 Android 操作系统自行决定WiFi Direct 组的名称

我什至尝试使用Reflection来实现相同的目的,但它在Android Nougat 及更高版本上不起作用。

我使用以下代码创建 WiFi Direct 组:

WifiP2pManager manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
WifiP2pManager.Channel channel = manager.initialize(this, getMainLooper(), null);
 manager.createGroup(channel, new WifiP2pManager.ActionListener() {
                @Override
                public void onSuccess() {
                    Toast.makeText(getApplicationContext(), "Group Created", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onFailure(int i) {
                    Toast.makeText(getApplicationContext(), "Group Creation Failed", Toast.LENGTH_SHORT).show();
                }
            });
Run Code Online (Sandbox Code Playgroud)

但是当我尝试 PDANet+ 应用程序时,他们能够创建一个带有后缀 PDANet 的 WiFi Direct 组名称。

例如:

我的应用程序生成以下组名称:DIRECT-mq-ONEPLUS

而 PDANet 生成:DIRECT-Dj-ONEPLUS A6000-PdaNet

所以我想知道他们如何将后缀添加到 WiFi Direct 组名称中。如果有人能在这方面帮助我,那将会有很大帮助。!

谢谢。!

android ssid android-wifi wifi-direct wifip2p

6
推荐指数
0
解决办法
359
查看次数

ARM Chromebook 上的 Android 开发环境?

我曾多次尝试在ARM Chromebook (C100P)上安装和使用Android Studio,但安装总是失败并显示错误。我读到这是因为 Android Studio 依赖于与 ARM 处理器架构不兼容的本机二进制文件;即使在尝试了各种 hack 或只是尝试单独使用这些库之后,我仍然无法在我的 ARM Chromebook 上设置 Android 开发环境。failed to run mksdcard tool

android arm chromebook android-studio

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

如何在android中的textview上使用红色*符号

我有一个文本视图.文本视图是必需的,因此我希望*文本视图顶部的符号为红色.在此输入图像描述

java android textview

2
推荐指数
2
解决办法
2327
查看次数

RatingBar主题在Marshmallow工作但不在Lollipop工作

我正在尝试使用以下代码设置我的RatingBar样式:

<style name="RatingBarfeed" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">@color/white</item>
    <item name="colorControlActivated">@color/duskYellow</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在layout.xml中,我使用以下代码:

<android.support.v7.widget.AppCompatRatingBar
        android:theme="@style/RatingBarfeed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?android:attr/ratingBarStyleSmall"
        android:id="@+id/ratingBar"
        android:paddingBottom="0.45dp"
        app:layout_constraintTop_toTopOf="@+id/rating"
        app:layout_constraintLeft_toRightOf="@+id/rating"
        app:layout_constraintBottom_toBottomOf="@+id/rating"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        android:background="@color/orange"
        android:rating="3.5"
        android:stepSize="0.5"/>
Run Code Online (Sandbox Code Playgroud)

它在Marshmallow工作正常(查看截图) 在此输入图像描述

但在Lollipop主题不起作用(查看截图) 在此输入图像描述

请帮忙...!!!!

android ratingbar android-styles

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

Is the value of an Android phone's radio type always GSM, LTE, CDMA or WCDMA?

I'm creating an app that uses Google's Geolocation API, as documented here.

As part of the POST request I need to send to their API, I need to include The mobile radio type, radioType. The question of how to receive that has already been asked and answered here.

My question is as follows:

telephoneManager.getNetworkType()我显然应该使用的函数返回 18 个值之一,在此处记录为常量。

这是否意味着radioTypeGoogle 的地理定位 API 所描述的真的可以是 18 个不同的值?因此,如果事实证明我的无线电类型不是他们支持的四种类型(GSM、LTE、CDMA 或 WCDMA)之一,那么我只是运气不好,将不得不因不包括radioType在我的请求中而损失准确性?

我有一种感觉,我正在混淆这些术语radio typenetwork …

java android google-api radio

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

将match_parent转换为“ 0dp”

当我在“约束布局”中将android:layout_height="match_parent"android:layout_width="match_parent"用作子项的高度/宽度并构建Gradle文件时,它将自动更改为android:layout_height="0dp"android:layout_widtht="0dp"

从技术上讲,0dpmatch_parent之间存在巨大差异。

在大多数情况下,它不会影响我的布局,但有时这东西会完全破坏我的约束布局。

我不知道为什么会这样。
请指导我。

android android-layout android-studio android-constraintlayout

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