小编sun*_*rer的帖子

选项卡图标未显示

我正在尝试用两个标签在android中做一个简单的标签应用程序.我的问题是,当我把这个代码放在选项卡中时,只显示文本,但没有显示图标.如果我将文本放到"",则显示图标.

有人能帮助我吗?我的Android版本是4.0.3.

非常感谢.

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/tabhost"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" >
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

     <TabWidget android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@android:id/tabs" />

     <FrameLayout android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@android:id/tabcontent" >

        <LinearLayout android:id="@+id/tab1"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
            <TextView android:id="@+id/textView1"
                android:text="Contenido Tab 1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
    </LinearLayout>

        <LinearLayout android:id="@+id/tab2"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
            <TextView android:id="@+id/textView2"
                android:text="Contenido Tab 2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
    </LinearLayout>

     </FrameLayout>
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)

而活动代码是

public class TabTestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle …
Run Code Online (Sandbox Code Playgroud)

tabs android android-tabhost android-4.0-ice-cream-sandwich

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

Android:如何在一个Vector Drawable xml中使用选择器更改android:fillcolor

选项卡图标:我当前的方法是创建两个文件(ic_list_selected_24dp.xml和ic_list_unselected_24dp.xml;它们基本相同但只是android:fillColor='Color HEX CODE'不同),然后创建一个选择器(selector_tabitem_list.xml)来更改状态时的可绘制颜色改变了.

// @drawable/selector_tabitem_list.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto">
    <item android:drawable="@drawable/ic_list_selected_24dp" 
        android:state_selected="true" />
    <item android:drawable="@drawable/ic_list_unselected_24dp" 
        android:state_selected="false" />
</selector>
Run Code Online (Sandbox Code Playgroud)

它有点复制,因为两个drawable是相同的.

选择器不能用于矢量drawable.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
    <path
        android:fillColor="@drawable/selector"
        android:pathData="M19,3...."
</vector>
Run Code Online (Sandbox Code Playgroud)

-

// @drawable/selector

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true">
        <color android:color="@color/itemSelected" />
    </item>
    <item android:state_selected="false">
        <color android:color="@color/itemUnselected" />
    </item>
</selector>
Run Code Online (Sandbox Code Playgroud)

,android:fillColor="@color/state"或者.

// @color/state

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@android:color/white" android:state_selected="true" />
    <item android:color="@android:color/black" android:state_selected="false" />
</selector>
Run Code Online (Sandbox Code Playgroud)

有没有办法使用一个drawable并动态更改其颜色?使用硬十六进制代码更好?

谢谢.

android android-tabs android-selector android-tablayout android-vectordrawable

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

ClassNotFoundException"android.support.v4.graphics.drawable.DrawableWrapper"

什么可以DrawableWrapper从支持lib 导致类的错误?

Caused by: java.lang.ClassNotFoundException: Didn't find class 
"android.support.v4.graphics.drawable.DrawableWrapper" on path: 
DexPathList[[zip file "/data/app/com.example.banyan.tasty-
1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
Run Code Online (Sandbox Code Playgroud)

android android-support-library

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

带有多个模块的 Android 上的 Firebase 推送通知

我目前正在尝试在我们的应用程序中实现推送通知。

所以我们有三个模块。

  • 应用 1
  • 逻辑
  • 应用 2

我给了他们明显的名字。App 1 和 2 依赖于逻辑模块。此模块包含两个应用程序的所有逻辑。现在,我希望向在 App 1 或 App 2 上登录的用户发送特定于 App 的通知。

问题:

我无法将 firebase 逻辑放入 Logic 模块,因为该模块被配置为 lib 模块并且未配置为应用程序。现在我必须将 firebase 逻辑放在 App 1 和 2 中,但我无法从 Logic 模块访问此逻辑,因为 App 1 和 2 依赖于 Logic 模块,而不是相反。

Firebase 需要为每个连接的应用程序提供一个 google-services.json,需要此文件来生成用户特定的 pushtoken。

有没有办法配置它,以便我可以为推送通知生成用户特定的令牌?因此,在用户登录后,必须根据应用程序和用户生成推送令牌,以便该用户可以在他/她登录的所述设备上获得通知。

我希望这已经足够清楚了。

android push-notification firebase

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

如何在build.gradle中指定admob库?

我可以在Android Studio的build.gradle中指定AdMob库,以避免在本地使用AdMob jar吗?

我试过了

dependencies {
    compile 'com.google.ads:6.2.1+'
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我错过了什么吗?

android gradle admob android-studio

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

Android-如何删除setError()的感叹号

我的xml代码的密码字段部分:

<android.support.percent.PercentRelativeLayout
    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="match_parent"
    >
...

    <android.support.design.widget.TextInputLayout
        android:layout_below="@+id/uname_ly"
        android:id="@+id/text_input_layout_passwd"
        app:layout_widthPercent="70%"
        android:layout_centerHorizontal="true"
        app:layout_heightPercent="10%"
        app:layout_marginTopPercent="0%"
        app:layout_marginBottomPercent="0%"
        android:adjustViewBounds="true"
        android:textColorHint="@color/editTextHintColor"
        app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
        >

        <EditText
            android:id="@+id/password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/nopasswd"
            android:inputType="textPassword"
            android:maxLines="1"
            android:textColor="@color/editTextTextColor" />

    </android.support.design.widget.TextInputLayout>
...
Run Code Online (Sandbox Code Playgroud)

调用setError()时如何删除此重叠的红色感叹号? 在此处输入图片说明

[更新样式]

<style name="TextAppearance.App.TextInputLayout" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/editTextHintColor</item>
</style>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-edittext android-styles android-textinputlayout

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