android-xml

How to get all Buttons ID's in one time on Android

旧时模样 提交于 2020-06-24 07:37:41
问题 I have 16 Button s in my Activity and I have to initialize those inside onCreate(). Is there any way to initialize all buttons in one single line code?(loops etc.) Code should take all buttons R.id. from XML Layout and process.... 回答1: Let's say you named your button button_0, button_1, .. button_15 . You can do: for (int i = 0; i < 16; i++) { int id = getResources().getIdentifier("button_"+i, "id", getPackageName()); button[i] = (Button) findViewById(id); } 回答2: Well, if all 16 of those

How to use specified weights for fonts in XML

南楼画角 提交于 2020-05-24 08:09:07
问题 Using the Fonts in XML feature you can specify various font weights for a font family. For example: <?xml version="1.0" encoding="utf-8"?> <font-family xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <font android:font="@font/archivo_narrow_regular" android:fontWeight="400" android:fontStyle="normal" app:font="@font/archivo_narrow_regular" app:fontWeight="400" app:fontStyle="normal"/> <font android:font="@font/archivo_narrow

How to set a layout width percentage of one third on ConstraintLayout?

坚强是说给别人听的谎言 提交于 2020-05-16 02:27:27
问题 I want to fill the screen in a two-dimensional grid of 3x6 TextViews. This means that each TextView must be 1/3 of the full screen width and the height 1/6 of the full screen height. I am using a ConstraintLayout for this layout, since LinearLayouts are bad practise for this layout as nested weights are bad for performance. Currently, I am using the percentage 0.333333333333333 and 0.166666666666667 for respectively the width and height, as shown below. <TextView app:layout_constraintLeft

Right to left menu items Android

雨燕双飞 提交于 2020-04-10 15:13:10
问题 I have an Slide menu as picture one. And i need to align its items title to be right to left like slide two . I tried gravity=right but didn't work. Here is my code : <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:gravity="end" android:layout_gravity="end"> <group android:checkableBehavior="single" android:layout_gravity="end" android:gravity="end"> <item android:id="@+id/nav_1" android:icon="@drawable/ic_keyboard

Right to left menu items Android

给你一囗甜甜゛ 提交于 2020-04-10 15:08:23
问题 I have an Slide menu as picture one. And i need to align its items title to be right to left like slide two . I tried gravity=right but didn't work. Here is my code : <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:gravity="end" android:layout_gravity="end"> <group android:checkableBehavior="single" android:layout_gravity="end" android:gravity="end"> <item android:id="@+id/nav_1" android:icon="@drawable/ic_keyboard

How do I force eclipse to show xml layouts and styles as text?

五迷三道 提交于 2020-02-21 13:24:04
问题 I recently moved up to Eclipse 4.2 (Juno) with ADT 20.0.3. If I view a layout or a style from an old project Eclipse just shows me its appropriate controls-based editor. I want to edit the syntax-highlighted xml text. I don't see a way to switch the plugin's editor to this mode although it will fallback to it for a layout it chokes on and can't give a WYSIWYG display for. Any help will be appreciated. EDIT : This problem turned out to be a side effect of my recent adventures in themeing

RecyclerView is not trully wrap_content at the ScrollView

可紊 提交于 2020-02-01 05:29:24
问题 I have a ScrollView, which contains a vertical LinearLayout. This is a place, where I add some amount of Views called "Section". "Section" is a LinearLayout, which contains a TextView and `RecyclerView. <ScrollView android:id="@+id/main_scrollview" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/sections_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" /> </ScrollView>

Issues with creating new Android MainActivity

左心房为你撑大大i 提交于 2020-01-25 03:39:28
问题 I'm new to Android programming and am attempting to create a new Main Activity for my app (taken from the Android tutorial website). My original Main Activity is called "MainActivity". The new activity I want to be my Main Activity is called "Homepage" and it should contain a button that produces "MainActivity" upon clicking. I'm unsure what or where I'm supposed to include information in the manifest regarding the new page "homepage", homepage.xml, and the button. Specific code would be

Android XML cutting off bottom half of layout

自闭症网瘾萝莉.ら 提交于 2020-01-24 02:12:09
问题 I have a problem with my XML layout, something that I thought wouldn't give me many problems. I have a layout below in a scroll view, but the bottom of the layout is being cut off , I can't see anything past the second list view. From looking around, I can't seem to see anything wrong with the xml itself and I can't see what I am doing wrong. I have tried the suggestion to the problem, that is adding a weight to each of the different elements but this still hasnt solved the problem. I have

Is it possible to replace dots in password (EditText) with custom view?

给你一囗甜甜゛ 提交于 2020-01-17 05:09:08
问题 I want to replace dots in EditText ( android:inputType="textPassword" ) with custom xml or image. I can replace dots with any other symbol using PasswordTransformationMethod method, but this is not what is required in this case. So, is it possible? Thanks. 回答1: There is Span API for Edit text. You could use TextWatcher in connection with ImageSpan. Also Don't forget about copy/paste functionalty in secure reson. So solution is listening text input, and wrap it with ImageSpans. when you want