eluleci / FlatUI

Android FlatUI Kit
1.66k stars 422 forks source link

Rendering problems on Android Studio #11

Closed ernes87lp closed 10 years ago

ernes87lp commented 10 years ago

Hi, I'm having this issue on Android Studio, I don't know how to fix it. It's weird because I did a test a month ago and everything worked fine. I'm using the API 19. I'm trying to add a simpel edit text. Also, if I run the app on the emulator, the control is not rendered properly.

Here's a screenshot of the error.

rendering

And here's the layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:flatui="http://schemas.android.com/apk/res-auto"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:background="@color/background">

<com.cengalabs.flatui.views.FlatTextView
        android:id="@+id/etUsername"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:layout_marginLeft="5dip"
        android:maxLines="1"
        android:gravity="center_vertical"
        android:text="Edit Texts"
        flatui:textColor="main"
        flatui:theme="@array/candy"/>
</RelativeLayout>

Thanks in advance

u3amar commented 10 years ago

I'm also getting this error in Eclipse.

u3amar commented 10 years ago

I was able to fix this problem by editing the Attributes class. I changed the setThemeSilent and setTheme methods and added a method:

public void setTheme(int theme, Resources resources)
{
    this.theme = theme;

    try
    {
        colors = resources.getIntArray(theme);
    }
    catch (NotFoundException e)
    {
        checkNullColors();
    }

    attributeChangeListener.onThemeChange();
}

public void setThemeSilent(int customTheme, Resources resources)
{
    this.theme = customTheme;

    try
    {
        colors = resources.getIntArray(customTheme);
    }
    catch (NotFoundException e)
    {
        checkNullColors();
    }
}

private void checkNullColors()
{
    if (colors == null)
    {
        colors = new int[4];
        colors[0] = Color.parseColor("#ad843d");
        colors[1] = Color.parseColor("#d4a14a");
        colors[2] = Color.parseColor("#fbbf58");
        colors[3] = Color.parseColor("#fae8c8");
    }
}

When viewing the UI through the UI builder, Eclipse isn't able to find the request integer array using the resources, so it throws a NotFoundException. Whenever this happens, we make sure the colors are being set using the default color scheme for the sand theme. This is not an ideal solution because it means we can't view other themes in the UI builder, but it does allow us to edit the positions of elements on screen.

eluleci commented 10 years ago

I fixed this issue but didn't update the repository yet. Thanks @u3amar for suggestion. I'll close the issue and comment when the repo is updated.

eluleci commented 10 years ago

This issue is fixed with version 2.0.1