[GUIDE] Quantum Paper UI

Search This thread

Sahaab

Senior Member
May 14, 2013
3,722
3,499
27
London ON
Yeah, defiantly. It should work as the images don't need a specific api level.
And good luck mate!

Sent from my Nexus 5 using Tapatalk

i use the exact same code you gave, and i just keep getting an overflow logcat for the ImageButton
i have tried making various changes, but still same thing :-/
it gets fixed inside eclipse, but still doesnt work on my phone :-/

Edit: Log

Code:
06-18 18:04:28.595: E/AndroidRuntime(1138): FATAL EXCEPTION: main
06-18 18:04:28.595: E/AndroidRuntime(1138): Process: com.ashutos.quantumpaperui, PID: 1138
06-18 18:04:28.595: E/AndroidRuntime(1138): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ashutos.quantumpaperui/com.ashutos.quantumpaperui.MyActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class android.widget.ImageButton
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.ActivityThread.access$800(ActivityThread.java:135)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.os.Handler.dispatchMessage(Handler.java:102)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.os.Looper.loop(Looper.java:136)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.ActivityThread.main(ActivityThread.java:5017)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at java.lang.reflect.Method.invoke(Method.java:515)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at dalvik.system.NativeStart.main(Native Method)
06-18 18:04:28.595: E/AndroidRuntime(1138): Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class android.widget.ImageButton
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.createView(LayoutInflater.java:620)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.Activity.setContentView(Activity.java:1929)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at com.ashutos.quantumpaperui.MyActivity.onCreate(MyActivity.java:14)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.Activity.performCreate(Activity.java:5231)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	... 11 more
06-18 18:04:28.595: E/AndroidRuntime(1138): Caused by: java.lang.reflect.InvocationTargetException
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at java.lang.reflect.Constructor.constructNative(Native Method)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.view.LayoutInflater.createView(LayoutInflater.java:594)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	... 27 more
06-18 18:04:28.595: E/AndroidRuntime(1138): Caused by: java.lang.StackOverflowError
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.DrawableContainer$DrawableContainerState.<init>(DrawableContainer.java:511)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.StateListDrawable$StateListState.<init>(StateListDrawable.java:281)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.StateListDrawable.<init>(StateListDrawable.java:327)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.StateListDrawable.<init>(StateListDrawable.java:75)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:898)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.content.res.Resources.loadDrawable(Resources.java:2092)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.content.res.Resources.getDrawable(Resources.java:700)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.content.res.Resources.loadDrawable(Resources.java:2092)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.content.res.Resources.getDrawable(Resources.java:700)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.content.res.Resources.loadDrawable(Resources.java:2092)
06-18 18:04:28.595: E/AndroidRuntime(1138): 	at android.cont

Edit 2 : working just fine without button

Edit 3: Figured it out
 
Last edited:
G

GuestD2623

Guest
Guys how can i add menu to the imagebutton thing ?
so when i click it a option bar show so i can add some other activities.

and thanks alot for the guid thread.
 

TheArc

Inactive Recognized Themer
Jan 1, 2012
2,512
2,122
26
Auckland
I've updated the first thread with new content and fixes.
I've also added a sample source code for Eclipse and an installable apk.
This can be found above the "What you'll Need" section.
 
  • Like
Reactions: Sahaab

Top Liked Posts

  • There are no posts matching your filters.
  • 28
    rERUyn5.png


    As we all know, Google's planning something quite new for it's beloved Android users. So after examining and researching more into Google's new project Quantum Paper.
    I have created a resource base for your project layouts, so you can make your app look more like Google's upcoming project Quantum Paper.
    Please note - I have added explanations as there new comers to Android development and perhaps these explanations will help them understand what these certain files do.

    Outcome design - One of my simple projects, click here to see what it'll look like.
    Project source code and installable apk - click here.

    What you'll need -

    [x] Eclipse, Android Studio or any Android app developing IDE.
    [x] Paint.NET or any image editor.
    [x] My custom resource package - Download
    [x] Some experience with the IDE that you're using, as I will not be showing you how to use it.

    Setup -

    Create the following folders and files in your project.
    [x] A directory named drawable.
    [x] A directory named drawable-nodpi.
    [x] A file named colors.xml in the values directory.

    Explanation -

    Drawable folder - The reason you need a folder named drawable is because we want to create code based images. This is a better approach to things that deal with button clicks, layouts and such. This eliminates warped layouts and stuff.

    Drawable-nodpi folder - Since I have made UI images just by using screenshots and the information provided, I cannot present you with a proper dpi image.
    But on the other hand, these .pngs are high quality so don't worry about it being unclear.

    Colors.xml - An easy way to store preset hex colour codes in Android. It's made so you do not have to enter hex codes manually or for people that just want to link it to the colour they want with the name provided with the hex colour, it's sort of like an ID.

    Let's start

    Okay, the first thing you will have to do is, unpack the resource file I have provided you with somewhere appropriate, such as the desktop.
    Navigate to Action Bar Colors and open the colors.xml file. From there, copy and paste the colours you know you'll be working with in your projects colors.xml file. Now navigate to the Card Layout directory and copy bg_card.xml to your projects drawable directory.

    Now head into the Menu Buttons directory. And you will be greeted with two folders, one named normal and the other named pressed. Copy the coloured menu button that you wish to use from both directories to your projects folder named drawable-nodpi. For example, if you want to have a blue ActionBar, then go ahead and copy menu_button_blue and menu_button_blue_pressed.

    Now we can go ahead and create our selectable menu buttons.

    Create an .xml called menu_button_colorname. For exmaple - menu_button_blue.xml in the drawable folder.
    I named it blue because the menu buttons are blue, if it's another colour please link it to that to make things easier.
    Add the following code inside the .xm file you have just created. (menu_button_blue.xml/whatever the colour name is)

    Code:
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@drawable/[COLOR="RoyalBlue"]menu_blue_pressed[/COLOR]"/>
    <item android:state_pressed="true" android:drawable="@drawable/[COLOR="rgb(65, 105, 225)"]menu_blue_pressed[/COLOR]" />
    <item android:drawable="@drawable/[COLOR="rgb(65, 105, 225)"]menu_blue[/COLOR]" />
    </selector>

    Replace the lines in red with the resource colour name. ie - menu_button_green, if you're making a green button.
    For example, if I have a green action bar, and I have chosen my green menu buttons. I will change the blue to green, like below -

    Code:
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@drawable/[COLOR="rgb(152, 251, 152)"]menu_green_pressed[/COLOR]"/>
    <item android:state_pressed="true" android:drawable="@drawable/[COLOR="rgb(152, 251, 152)"]menu_green_pressed[/COLOR]" />
    <item android:drawable="@drawable/[COLOR="PaleGreen"]menu_green[/COLOR]" />
    </selector>

    Now go into activity_main.xml (The main layout, this may be different if you have changed the name). And replace all the code with this following code -

    Code:
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/blue"         <!--  Change the main window colour to whatever colour you like  -->
        tools:context=".MainActivity" >
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#eeeeee" 
            android:orientation="vertical" >
    
            <RelativeLayout
                android:id="@+id/action_bar"
                android:layout_width="fill_parent"
                android:layout_height="60dp"
                android:background="@color/blue" >         <!-- This should be the same colour as your main window background  -->
    
                <ImageButton
                    android:id="@+id/qpaper_menu"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:background="@drawable/menu_button_blue" />         <!--  This should be the same colour as your action bar layout -->
    
                <TextView
                    android:id="@+id/app_header_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@+id/qpaper_menu"
                    android:text="You applications name"         <!--  Change it to your apps name -->
                    android:textColor="#fff"
                    android:textSize="18sp" />
            </RelativeLayout>
    
           <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="350dp"         <!-- Change this to what ever height you want to make the layout bigger  -->
                android:layout_margin="12dp"
                android:background="@drawable/bg_card"
                android:orientation="vertical" >
    
            </RelativeLayout>
    
        </LinearLayout>
    
    </RelativeLayout>

    The code above is a pre-set template layout. So you will have to do some experimental and edits to the code, I have supplied the code with minor notes to help you. Also many of you guys would probably wish to add more card views than just one.
    To add more card views add the code below under the original card view, you can see it above.

    Code:
           <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="350dp"         <!-- Change this to what ever height you want to make the layout bigger  -->
                android:layout_marginLeft="12dp"
                android:layout_marginRight="12dp"
                android:layout_marginBottom="12dp" <!-- Ihave not added marginTop because you don't want to have a huge gap between your card placements -->
                android:background="@drawable/bg_card"
                android:orientation="vertical" >
          </RelativeLayout>

    And yes, you can add scrollable views without issues, so you can scroll through your interface ;).
    I will be updating this thread regularly with new info, package updates with new resources and new guide sections.

    2
    This is Fantastic!
    Here is a patchwork job I did of the Google+ and Youtube card interfaces. It looks like they made the shadow a bit subtler and added a 1 px border that goes from dark to slightly lighter on the top. This is probably part of their Hera/Moonshine UI, do you think it'll be part of Quantum Paper cards, too? If so, I'm not able to figure out how to define it in an XML relative to what you've posted.
    Again, great tutorial and starter project!!

    See below:
    ugR1Gt7.png
    I will definitely take a look at this, and try and see if I can make something similar to this. I'll defiantly update the thread if I find a way.
    Great job on reaching portal. Shouldn't be surprised from your previous works. Are you planning on adding these changes to your themed apps?
    Thanks! And I haven't recently released any new themed applications so I'm unaware if I will do so.

    I've created some extra .pngs and will be updating the resource package do there is a better selection of buttons.
    @Fitchman I have found a workround - Let me know if it works.

    Click here
    2
    Beautiful! This is how it looks.... Thanks for such resources!!!

    2KAfUm9.jpg
    2
    Thank you for this :)
    One mistake though, the parts in bold and underlined should be removed.
    thanks for pointing it out, I'll edit the thread sometime.

    Sent from my Nexus 5 using Tapatalk
    1
    Thank you for this :)
    One mistake though, the parts in bold and underlined should be removed.

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@drawable/[COLOR="Red"]menu_[b][u]button_[/b][/u]blue[/COLOR]"
            android:state_focused="true"
            android:state_pressed="true" />
        <item android:drawable="@drawable/[COLOR="red"]menu_[b][u]button_[/b][/u]blue_pressed[/COLOR]"
            android:state_focused="false"
            android:state_pressed="true" />
        <item android:drawable="@drawable/[COLOR="red"]menu_[b][u]button_[/b][/u]blue_pressed[/COLOR]"
                android:state_focused="true" />
        <item android:drawable="@drawable/[COLOR="red"]menu_[b][u]button_[/b][/u]blue[/COLOR]"
            android:state_focused="false"
            android:state_pressed="false" />
    </selector>