Remove Extra Space between Views - java

I'm building a simple calculator app and i cannot get ride of extra grey lines next to an ImageButton
Button Code
<Button
android:id="#+id/button_clear"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/white"
android:text="AC"
android:textColor="#color/indigo"
android:textSize="18sp" />
ImageButton Code
<ImageButton
android:id="#+id/button_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/backspace"
android:background="#color/white"/>
As you can see, the buttons are perfect but the ImageButton have grey lines next to them.
I tried settings the Parent background to 'White' and setting the ImageButton background to '#null' too
I tried an Imageview and the Problem still exists
i tried setting the image as background to the button and it still exists
i even tried setting negative margin towards left and right and the problem still exists
Can someone help me out please?

Add this in your ImageButtons
style="?android:attr/borderlessButtonStyle"

I have a suggestion: Use a button to display the ⌫ symbol. For information on how to get the desired results visit: How to make ⌫ symbol backward-compatible in Android Studio?

Related

How can I change the font size in Android Studio?

I don't want to change the font size of Android Studio itself, but rather the font size of the app i'm working on. All the search results I have found talk about the user interface or zooming in.
I'm Working on a tic-tac-toe beginner project and the button text always is so small. Any tips on how to increase it?
Here is its part in the xml file:
<Button
android:id="#+id/button_0"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
Many thanks in advance for anyone who helps
Add android:textSize property into Button, eg:
<Button
android:id="#+id/button_0"
android:layout_width="0dp"
android:textSize="20sp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
https://developer.android.com/reference/android/widget/TextView#attr_android:textSize
One way is to change the textSize attribute in the XML file. The other way is to mention it in the program.
Button btn = findViewById(R.id.button_0);
btn.setTextSize(20.0f);
where btn is the name of the button.
Note: The size mentioned in the setTextSize() method must be a float value.

Android: Scale background image of RadioButton or another way to make a RadioButton an Image

I'm making an app that is related to a card game and as such has many images of cards appear throughout the app. In one section I need the user to select one of four cards, with only one selection ever being possible and I want to have the card to change color slightly after being clicked to show that it is the currently selected one.
For the bulk of this task a RadioGroup with RadioButtons makes perfect sense since the functionality for having a checked/unchecked state and unselecting all other options when a new one is picked is built in; however, the issue is that I want the buttons to be the cards themselves and therefore an image with no text whatsoever.
At first this post looked promising: Adding custom radio buttons in android
My use of this strategy:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="5"
android:orientation="horizontal">
<TextView
android:id="#+id/label_seatGod"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="8"
android:gravity="center_vertical"
android:text="#string/ex2"
android:textColor="#color/font_condition_labels"
android:textSize="#dimen/font_gen_label_size"
android:textStyle="bold" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="8" >
<RadioButton
android:id="#+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#drawable/power_aphrodite"
android:checked="false"
android:text="#null" />
</RadioGroup>
</LinearLayout>
which resulted in:
This is almost perfect. No text and the entire region of the clickable button space is composed of the image I want, EXCEPT that as you can see the image is not scaled at all and is cropped on the edges. Above the RadioButton you can see a LinearLayout with 4 ImageButtons that demonstrate exactly how I want the RadioButton/card image to appear (ignore the grey for now I haven't finished padding the views).
Essentially, I want a RadioButton that functions normally but looks exactly like one of the four ImageButtons in the top section. Ideally scaleType="fitCenter" would be the fix since it is what I am using in the example ImageButtons, but you cannot apply that attribute to the button drawable of a RadioButton or its background directly.
So how can I get the image to scale and not be cropped without resorting to some performance tanking layout jurry rigging or creating an entirely new RadioButton class?
Thanks in advance.
Maybe you could try adding this to your RadioButton in the xml:
android:scaleType="centerCrop"

How can I add two button (one is back, one is next) under scrollview that filled with textview and imageview in a screen, android?

I want to ask, can I add next and back button under scrollview that filled with textview and imageview in one screen, both with it's xml, java and screenshot result for android?
Here's the picture I intend to ask.
I got from here: https://sensortower.com/android/nl/softartstudio/app/selfishop-camera/com.selfishop.camera/
enter image description here
Where actually, what I really aim is a view like a blog (when you see an image on your above text that can be scrolled, where it's end with Back button that will go to previous page on the bottom left, and Next button that will go to the next page at the reverse side).
Really would like an example in xml, java, and it's screenshot result.
Again, thank you very much
Very appreciate your answer. Thank you
This is what XML is for.
Create your layout in xml and import it via java.
You will want to create your own "bar layout" for the bars in the center, though you could I suppose, fill 3 separate LinearLayouts to achieve the same effect, making a separate layout and putting in it here will be easier for you to read, and follow along with what is happening.
Below is a mock up of the xml layout you would be using to get a view very similar to what you have in your picture. I have not tested this, this was made on the fly so it may not be perfect but it will get you very close to what you are looking for.
<LinearLayout>
android:orientation="vertical"
android:weightSum=10
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout>
android:weight=1
android:layout_height=0dp
android:layout_width="match_parent">
<TextView>
android:width="wrap_content"
android:id="#+id/info_bar"
android:centerHorizontal="true"/>
</RelativeLayout>
<LinearLayout>
android:weight=8
android:width="match_parent"
android:height=0dp>
<TextView>
android:id="#+id/text_view1"
android:width="match_parent"
android:height="wrap_content"/>
<com.yourpackage.yourapp.createabarlayout>
</com.yourpackage.yourapp.createabarlayout>
<com.yourpackage.yourapp.createabarlayout>
</com.yourpackage.yourapp.createabarlayout>
<com.yourpackage.yourapp.createabarlayout>
</com.yourpackage.yourapp.createabarlayout>
</LinearLayout>
<RelativeLayout>
android:weight=1
android:layout_width="match_parent"
android:layout_height=0dp>
<Button>
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/back_button"
android:text="#string/back_button_hint"/>
<TextView>
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/steps_textview"
android:text="#string/steps_hint"
android:centerHorizontal="true"/>
<Button>
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/next_button"
android:text="#string/next_button_hint"/>
</RelativeLayout>
</LinearLayout>

cant seam to get a full screen listview on a tv screen

hi guys my listview seams to get a boarder on the left and right edge. this only happens on xl devices such as tv screens. i had the same problem with my webview a few weeks ago and remember using a setting for wideviewport. is there a way of doing the same sort of thing but for a list view?
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/lvDownloadbuttons"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:scrollbarThumbVertical="#drawable/scrollbar"
android:splitMotionEvents="true"
/>
Ive tried adding this line to my xml code but does nothing.
android:fillViewport="true"
also tried adding
android:layout_weight = "1"

Android placing multiple bitmaps in imageview

I have multiple ImageViews which are transparent and are meant to over lap one another. I am aligning then to one another but one problem presist. How can I set the order in which they are layered? Ive tried revising the code in both xml and how the images are set in the actual java code...
I have tried FrameLayout but maybe Im not using it right...here is my implementation:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".RadarActivity" >
<ImageView
android:id="#+id/imageview_topo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:scaleType="center"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageview_counties"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:scaleType="center"
android:visibility="invisible" />
No matter what I do...imageview_topo is always placed on top. Even in the code i have instantated topo first and retrieved its image first!
Thank you!
I referred a site here that says:
If multiple child views exist, then they are drawn, in order, one atop
the other. This means that the first view added to the frame layout
will display on the bottom of the stack, and the last view added will
display on top.
You can check this site too: http://blog.neteril.org/blog/2013/10/10/framelayout-your-best-ui-friend/
May be i can help you more if you show the screenshot of your UI.

Categories