Add Double border to Text Field In Android App - java

I'm new to Android development. I want to know is there any way to add two border in a text field. one inside another so that When User provide Input the Inner Border turns blue or specified color?
Hint

You can create separate drawables for each
app the outer drawable to a linear layout and inside that linear layout put edittext and apply second drawable to that edittext

Related

Blueprint android studio item to top right by default

I'm currently trying to make a layout in android studio however, everytime I'm adding something to my component tree it stick to the top right corner of the blueprint. I can't put seem to attach to sides my object that I want to add in my visual
THIS IS WHAT IT SHOULD LOOK LIKE
enter image description here
THIS IS WHAT I HAVE :
enter image description here
You need to Change the layout from coordinate layout to constrain layout so that use can constrain at specific position,In Case You are Using Coordinate Layout Try "gravity"to align as Your Wish,
Extra:
Always try another layout inside constrain Layout..

How can I add more pictures and text in a textview?

I want to add images and text in a textview.
My code:
txtViewNews.setText(" text "+VAR11+" text");
txtViewNews.setCompoundDrawablesWithIntrinsicBounds(R.drawable.a1a, 0, 0, 0);
It works. On left side there is the image and on the right side there is the text.
But I want to add another image and another text under the first image and text. But how?
Use layout managers. Like Linear layout with vertical orientation in a grid layout. Nested Layout.
Can't understand why you need this while you can add listview which will grow when additional row will get added. Simple.

Eclipse android widget moving

I am designing my activity screen using eclipse but whenever I move an object e.g. a button it snaps around and I find it hard to position things where i want them.
Is there some setting I can change as as soon as I add a second button it snaps the other button to another position it is so annoying!
Also if I have an image button why can't i resize this, even with a normal button if i try to make it larger it just fits to the text and wont make the button bigger or it just flicks to a random place on the activity?
thanks
Probably you're trying to place components freely in the View but you're not considering the LayoutManager behavior. If you try to position your component in a LinearLayout, for example, the components will be placed following its rules, and these components will not stay where you drop them.
Try to understand better how the layouts works on Android. But for now, the AbsoluteLayout or RelativeLayout may be what you're looking for.
About the components size, you'll need to understand better how to use layout properties for these components. See the question How to size buttons for more information.

Image Click event in Java LibGdx

I am working on a Street Fighter Game. I need to have a character selection screen for the user. How can I do this character selection in Java libGDX? This is my image code. Can I do this using ImageClick event?
splashTexture1 = new Texture(Gdx.files.internal("assets/gui/Character1.PNG"));
splashTexture1.setFilter(TextureFilter.Linear, TextureFilter.Linear);
splashSprite1 = new Sprite(splashTexture1);
splashSprite1.setX(100);
splashSprite1.setY(180);
My suggestiong is using scene2d for menu or HUD stuff.
Check this out : https://github.com/libgdx/libgdx/wiki/Scene2d
scene2d is a 2D scene graph for building applications and UIs using a hierarchy of actors:
buttons
labels
sliders
text buttons
scrollable views (lists)
tables
your custom widgets
group of actors
You can add ClickListener to an actor. (In your case the actor is a Button)
You can do it in two ways. I'd recommend using both.
Common stuff
You can list images of all characters in a screen. And let the user select any one using one of the following.
Click event
Each image will have a separate ClickListener (If you have problem regarding that, you should search 'How to add clicklisteners to libgdx actors).
On clicking any image, the variable storing selected character (for the rest of the game) will be set with the image that has been clicked. And the screen is changed.
Keyboard event
One of the image will have focus drawn around it. The user can move focus around to other character images using arrow keys. When user presses enter, the character that currently has focus gets selected and the screen is changed.
Hope this helps.
I would recomend to use the Table-Layout from libgdx for it. Add an ImageButton to a Table and add an ClickListener to the ImageButton. Add the same Texture as up and down Texture and you are done. Maybe change it later so the user see that he has clicked a figure.
The Table gives you the ability to arrange those Buttons in the way you like and it's structured. Moreover it is easy to create a dynamic view, that does have new ImageButton for every new Texture you add to a folder for example. Just create a ScrollPane with a the Table of "figures" (which are the ImageButton with an listener) and you can add a bunch of it and let the user scroll down and up to check which he likes.

edittext inside an imageview

i have a edittext image that i created in photoshop. then i bring it into my app and put a edittext inside it(my imageview is a frame for my edittext). in fact, i put these two inside a relativelayout and my problem is that when i test my app in twho screen sizes, these two (imagebox and edittext) doesnt resize in the same value and always my edittext resizes much more than my imageview. i want these two in every situation stay together.
The best way in my opinion is to convert your image to a 9-patch, with the padding information matching the part of your image containing the actual input zone.
You can then set the 9-patch as the background of your TextView or EditText. You don't need any container to hold the image. You can even use a style for re-use.
The Android system will hande the resizing of the background, so you just don't have to do anything special after that
You want to be using a FrameLayout rather than a RelativeLayout if you're planning on using images.

Categories