Android image button format - android

I am making an Android app and have created some imagebuttons for navigation. However, when I assign images to the buttons, the height of the button is never fully filled by the images as can be seen here (the underlying button sticking out has been circled - more obvious in the large bottom button)
For my layout Ive used a Relative layout for the main view and a Linear layout (Vertical) to stack the buttons.
Apart from creating the buttons in xml and adding images to them, I have done no other coding on the buttons yet.
Been trying to figure out all the drawables first but its as confusing as a bag of cats.
Can anyone tell me why this is and how I can possibly fix it?

To me it just looks like you used
android:src="#drawable/image"
instead of
android:background="#drawable/image"
(That is assuming you are doing this through XML)

Related

Ideas how to build a screen with 100 Views added programatically

Right now I'm stuck how to manage to build a specific Activity in my app. I've added an image so I can explain my problem:
So first of all: all the content will be loaded from an API. "Static text" in my image means that I can define these parts in my activity.xml and don't have to do that in my Activity.java because these parts will be always the same for the screen (meaning the size of the elements, the content will be loaded from my API).
The green box should be horizontal scrollable or not depending how many boxes have to be shown here (1 to 3 possible).
The blue box will be generated in my Activity (in the end it should look like a table) and I want to define the layout of a single row in a separate xml (e.g. table_row.xml) so I could change it easily. This table can have up to 100 rows depending on how many are returned by the API.
So my problem right now is: Obviously this whole layout has to be scrollable so my first idea was to use ScrollView and a LinearLayout as child. But I read here on stackoverflow that the performance will be really poor if you use LinearLayout and add Views to it. So everyone recommended using a ListView for this part (meaning the blue box for my Activity). But that would mean only my blue box will be scrollable as you should not use a ListView in a ScrollView.
So my question is: How can I make this whole screen scrollable with a table dynamic in size without losing performance?
Put the first three layouts as ListView Header and make your blue box layout as the list view. By this you'll be able to scroll the complete View i.e. Blue Box, however the first three layouts will be static and won't scroll.

Possible Known Issue with Eclipse Layout Builder?

I'm building a layout within Eclipse for Android using the RelativeLayout. I lay down a simple stack of buttons one on top of each other. For some reason the button snaps to the first button position even though I clearly place it down on the last stack of buttons. I try everything to move it to the right position eventually I just let the layout builder stick it to the bottom of the screen edge.
When I try this view inside the app, the last button is magically snapped to some random spot usually near the top. Obviously incorrect. As a hunch I tried it again but I left it alone this time, when I laid the last button down again ( which within Eclipse Layout builder its snapped to the first elements position for some crazy reason). Surprisingly within the app itself it appears in the proper location. So this must be a bug with the Layout builder itself.
It looks horrible in Layout builder (almost unusable) and the position of UI elements totally wrong, is this some known bug with Layout Builder + Android or do I need some update or new SDK or something?
There are many reported complaints about the ADK Editor for Eclipse, but one alternative is to try DroidDraw
http://www.droiddraw.org/
The preference of some Android developers is to directly modify the XML. This often provides more flexibility as you can see the exact rules that are defined for your UI.
If you are looking at just stacking Buttons on top of each other, you may want to consider a LinearLayout.
http://developer.android.com/reference/android/widget/LinearLayout.html
This is a layout that arranges its children in a single column or a single row.
Relative layout every "view" is positioned relative to something else. It would help you to understand better if you look at the xml. You will see what each item is aligned on. It is difficult to get this layout right as you see especially when you design in eclipse and run on an avd or real device. Consider placing a linear layout inside the relative layout and your buttons in that. This way your button group is together in a row or column and next to this you could have text or something.hard to explain but group like things together and nest layout inside other layouts.frame layout only one item is viewable at a time,like pages in a book or slide images. I hope I explained this good. I have no idea why you would do buttons that way.absolute layout is x,y positions where you put it is where it stays. Like that's gonna work. Try a different screen density and things are bunched up in the corner.like I said the key is nesting the layouts

Arranging buttons in a circle (Android) with lines connecting them

I am attempting to create a Fragment for an Android application where I have either Buttons or ImageButtons programatically arranged in a circle, with lines drawn from them to the center of the View. However, I have become stumped as to how to do this.
From my understanding, I can create a custom View in which I can override the onDraw() to draw the lines, but I cannot put the Buttons in this way. I can overlay the custom View with a FrameLayout or the like, but I do not know what type of layout to use so that the buttons can be arranged in a circle (and that this will work for various screen sizes).
Furthermore, I have to ensure that both the drawn lines and the buttons will be able to be animated together (that is, for instance, the buttons and connecting lines can move off-screen at the same rate as if they were one entity).
I have seen this post, and it is actually very similar to what I would like to do! : Dynamically arrange Buttons around a Circle . However, I do not quite have a satisfactory understanding of the answer, particularly how a Button can be created in an onDraw() with onClick still functioning.
Any suggestions would really be appreciated!
I think CircleLayout created by dmitry-zaitsev may help you to create what you want.
It has very simple implementation like below.
<ru.biovamp.widget.CircleLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
app:angleOffset="90.0">
<!-- Add here any views you want -->
</ru.biovamp.widget.CircleLayout>
Second option is Creating a Rotating Dialer
Third option is Android-3D-Carousel.

Custom buttons arangement in Android

I'm trying to build an Android app where I would like to display some Buttons in various places, as in the demo image attached.
The challenge here is creating the custom buttons and arranging them.
As for the custom Buttons, I guess I could achieve that using CustomViews or a simple button with a Custom Drawable as Background.
Are these the right points to start, any other ideas?
On arranging them, I have no clue how to achieve that.
As Android_Crazy and Closeratio have already said, a RelativeLayout is the most suitable option for custom placement of buttons in general. However, for the exact placement of buttons pictured in your example, a LinearLayout would work just fine.
In a LinearLayout you may place views under or above eachother (with android:orientation = "vertical", relevant for your example) or next to each other (android:orientation = "horizontal"). You can also add margin to your views to alter the horizontal position (layout_marginLeft or layout_marginRight) or the vertical position (layout_marginTop or layout_marginBottom).
As for the buttons' appearance, I always use custom background drawables, usually with a custom xml to add a different drawable for when the button is being pressed or selected.

Suitable layout for grid of buttons in android

I am confused with the appropriate layout design to be used for grid of buttons. I want to display a "textview and EditText" at the top. Below that there should be a 3*4 grid/matrix of 12 buttons(like cell phone keys), following another three linear buttons at the bottom of the root layout. (upper layout should not overlap the bottom buttons).
It would be of great help if anybody guide me in this regard.
UI layouts are done using xml files. Read about it before you start
While this is not exactly what you want here is a something to get you going.

Categories

Resources