GVKun编程网logo

html – 仅将样式应用于input = text(css只允许应用纯色作为背景)

26

本文的目的是介绍html–仅将样式应用于input=text的详细情况,特别关注css只允许应用纯色作为背景的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解html–

本文的目的是介绍html – 仅将样式应用于input = text的详细情况,特别关注css只允许应用纯色作为背景的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解html – 仅将样式应用于input = text的机会,同时也不会遗漏关于有什么区别、Android TextInputLayout 和 TextInputEditText 带有轮廓边框并在轮廓框上方显示提示文本、android – 仅将样式应用于特定的TextView、android-如何在styles.xml中设置TextInputEditText的样式的知识。

本文目录一览:

html – 仅将样式应用于input = text(css只允许应用纯色作为背景)

html – 仅将样式应用于input = text(css只允许应用纯色作为背景)

我有这样的CSS代码

div ul li input{ width:70%}

如果我希望此样式适用于仅类型= text的输入元素,该怎么办?

最佳答案
使用属性选择器

div ul li input[type=text] { width: 70%; }

有什么区别" alt="有什么区别">

有什么区别">有什么区别

<html:text>和<input type="text">有什么区别?而且能不能具体说一下这两个的来源?哪个更好一点?

Android TextInputLayout 和 TextInputEditText 带有轮廓边框并在轮廓框上方显示提示文本

Android TextInputLayout 和 TextInputEditText 带有轮廓边框并在轮廓框上方显示提示文本

如何解决Android TextInputLayout 和 TextInputEditText 带有轮廓边框并在轮廓框上方显示提示文本?

我在我的应用程序中使用 TextInputLayout 和 TextInputEditText 作为用户输入,但现在我们需要不同的设计,如下图所示。我的意思是提示文本应该在轮廓框上方而不是在轮廓边框内。我确实尝试了几种方法,但无法确定可以帮助我实现这种 UI 的确切属性或样式。

  • 预期的用户界面:

Expected UI wireframe

  • 当前用户界面:

Current UI

  • 样式:
    <style name="TextInputLayoutAppearance"parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
         <item name="BoxstrokeColor">@color/text_input_Box_stroke_color</item>
         <item name="shapeAppearanceOverlay">
             @style/TextInputLayoutMaterialThemeRoundedShapeAppearanceOverlay
         </item>
         <item name="hintTextColor">@color/hint_color</item>
         <item name="android:textColorHint">@color/hint_text</item>
    </style>
    
    <style name="TextInputLayoutMaterialThemeRoundedShapeAppearanceOverlay" parent="">
         <item name="cornerFamily">rounded</item>
         <item name="cornerSize">@dimen/_8sdp</item>
    </style>
    

我不确定这是否可以通过样式实现,或者需要开发结合 TextView 和 TextInput 控件的自定义控件。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

android – 仅将样式应用于特定的TextView

android – 仅将样式应用于特定的TextView

我有两个主题,我在Android应用程序之间来回切换.在某些地方,我有TextViews,我想保持默认颜色.在其他地方,我希望它们是另一种颜色(让我们说橙色).在更改主题时,我只希望之前为橙色的TextView变为蓝色.

有没有办法在Android中执行此操作?我有一些想法,比如html / css中的类标记,但似乎找不到任何东西.

编辑:用html / css等价来澄清我所说的内容:

<div>This text is black</div>
<div>This text is red</div>

.redDiv {
    color:red;
}

解决方法:

假设您的应用程序中有两个主题:MyFirstTheme和MySecondTheme:

<style name="MyFirstTheme" parent="android:Theme">
    <item name="android:textViewStyle">@style/MyFirstTheme.TextView</item>
    [...]
</style>
<style name="MySecondTheme" parent="android:Theme">
    <item name="android:textViewStyle">@style/MySecondTheme.TextView</item>
    [...]
</style>

styles.xml中定义的textview样式可能如下所示:

<style name="MyFirstTheme.TextView" parent="@android:style/Widget.TextView">
    <item name="android:textColor">@android:color/black</item>
    [...]
</style>
<style name="MySecondTheme.TextView" parent="@android:style/Widget.TextView">
    <item name="android:textColor">@color/orange</item>
    [...]
</style>
<style name="PersistentTheme.TextView" parent="@style/MyFirstTheme.TextView">
    <item name="android:textColor">@color/red</item>
</style>

因此,当你有一个带有两个TextView的布局时,你可以通过不设置任何额外的东西来完全跟随活动主题,并且可以通过为其指定样式属性将其他外观应用于其他TextView实例:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

    <!-- This textview will change text color when other style applied -->
    <TextView
        android:id="@+id/tv_styledependent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <!-- This textview will always have the same (red) text color -->
    <TextView
        android:id="@+id/tv_persistent"android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/tv_styledependent" />

</RelativeLayout>

android-如何在styles.xml中设置TextInputEditText的样式

android-如何在styles.xml中设置TextInputEditText的样式

我在注册屏幕上使用TextInputEditText.我可以设置浮动标签的样式.我想使用样式在TextInputEditText的提示和文本上设置自定义字体.有谁知道这是怎么回事?

   <android.support.design.widget.TextInputLayout
        android:id="@+id/til_registration_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:paddingEnd="@dimen/default_view_padding_right_8dp"
        android:paddingStart="@dimen/default_view_padding_left_8dp"
        android:textColorHint="@color/colorSecondaryText"
        app:hintTextAppearance="@style/AppTheme.InputLayoutStyle"
        app:layout_constraintTop_toBottomOf="@id/textview_registration_title">

        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/registration_name"
            android:imeOptions="actionNext"
            android:singleLine="true"
            android:textColor="@color/colorPrimaryText" />
    </android.support.design.widget.TextInputLayout>

styles.xml

<style name="AppTheme.InputLayoutStyle" parent="TextAppearance.AppCompat">
    <item name="android:textColor">@color/colorPrimary</item>
    <item name="fontFamily">@font/lato_light</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="android:textViewStyle">@style/AppTheme.TextView</item>
    <item name="buttonStyle">@style/AppTheme.Button</item>
</style>

我想为整个应用程序设置样式.

解决方法:

旧问题,但值得回答.

只需在应用程序主题中设置“ textInputStyle”以设置TextInputLayouts的样式,并设置“ editTextStyle”以设置TextInputEditTexts的样式.

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="android:textViewStyle">@style/AppTheme.TextView</item>
    <item name="buttonStyle">@style/AppTheme.Button</item>
    <item name="textInputStyle">
        @style/MyCustomTextInputStyle
    </item>
    <item name="editTextStyle">
        @style/MyCustomEditTextStyle
    </item>
</style>

<style name="MyCustomTextInputStyle" parent="Widget.Design.TextInputLayout">
    <item name="android:textColorHint">@color/colorSecondaryText</item>
    <item name="hintTextAppearance">@style/any_style_you_may_want"</item>
</style>

<style name="MyCustomEditTextStyle" parent="Widget.AppCompat.EditText">
    <item name="android:textColor">@color/colorPrimary</item>
    <item name="fontFamily">@font/lato_light</item>
</style>

这会将相同的样式应用于应用程序中的所有TextInputLayout和TextInputEditText.

今天关于html – 仅将样式应用于input = textcss只允许应用纯色作为背景的介绍到此结束,谢谢您的阅读,有关有什么区别、Android TextInputLayout 和 TextInputEditText 带有轮廓边框并在轮廓框上方显示提示文本、android – 仅将样式应用于特定的TextView、android-如何在styles.xml中设置TextInputEditText的样式等更多相关知识的信息可以在本站进行查询。

本文标签: