android-xml

How can I access a BuildConfig value in my AndroidManifest.xml file?

喜夏-厌秋 提交于 2019-11-27 05:01:05
问题 Is it possible to access a BuildConfig value from AndroidManifest.xml? In my build.gradle file, I have: defaultConfig { applicationId "com.compagny.product" minSdkVersion 16 targetSdkVersion 21 versionCode 1 versionName "1.0" // Facebook app id buildConfigField "long", "FACEBOOK_APP_ID", FACEBOOK_APP_ID } FACEBOOK_APP_ID is defined in my gradle.properties files: # Facebook identifier (app ID) FACEBOOK_APP_ID=XXXXXXXXXX To use Facebook connect in my app, I must add this line to my

Add custom layout to toolbar

会有一股神秘感。 提交于 2019-11-27 04:29:40
问题 I followed this tutorial to give my app a regular toolbar with some tabs. I want to change the toolbar so it looks more like this: I want to add some text and images into the toolbar. How can I do this? activity_main.xml : <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

Unexpected namespace prefix “xmlns” found for tag LinearLayout

倾然丶 夕夏残阳落幕 提交于 2019-11-27 04:09:54
I am having an error in following xml file. "Unexpected namespace prefix "xmlns" found for tag LinearLayout" . I tried the solutions provided in other similar questions also but it didn't work for me. Same error is occurring in 3 lines where LinearLayout is used. <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/background" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"

?android:attr/selectableItemBackground

戏子无情 提交于 2019-11-27 03:52:25
问题 when writing my android app i used android:background="?android:attr/selectableItemBackground" I tried looking for attr.xml file that would be containing the source but i could not find it. Any ideas please on where i can find it. I found one attr.xml in C:\Program Files (x86)\Android\android-sdk\platforms\android-13\data\res\values but it did not have the attribute mentioned above. Can anyone lead me where I can find the xml resource with the attribute above? 回答1: I'm not that experienced

Android Zig-Zag layout

懵懂的女人 提交于 2019-11-27 02:58:49
问题 I'm in need of creating a receipt layout in Android. The idea is very simple, a rectangle layout with a zigzag top. Even, i have tried dashed line but nothing working. <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:color="#FF00" android:dashWidth="5dp" android:dashGap="5dp" /> </shape> 回答1: Try with this: https://github.com/beigirad/ZigzagView Support top and bottom Zigzag. <ir.beigirad.zigzagview.ZigzagView android:layout_width="match

Android: how to scale a layout with screen size

与世无争的帅哥 提交于 2019-11-27 02:33:21
问题 Consider this layout (pulled from here): I'd like to understand the principles behind making this layout scale with screen size. For the square, a custom onMeasure function works nicely: @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, widthMeasureSpec); } The width and height of the custom Togglebuttons and Imagebuttons below should scale to fill the remainder of the screen, minus layout_margins, and the text and images

Start Activity Intent on Clicking Text Inside Webview

自作多情 提交于 2019-11-27 02:28:14
问题 I have a webview in my xml which goes like below: <WebView android:id="@+id/webView" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_width="match_parent" android:layout_height="match_parent"/> I am loading the webview like this: String webView_text = "Lorem ipsum..............**<a><u>Link to fire intent</u></a>**"; WebView webView= (WebView) findViewById(R.id.webView); webView.loadData(String.format(htmlText, webView_text), "text/html", "utf-8"); webView

Android button with different background colors

点点圈 提交于 2019-11-27 00:08:45
问题 i want to change the background-color of a button using a selector-xml-file. My approach is basically the one from the example at the bottom this page: http://developer.android.com/guide/topics/resources/color-list-resource.html i have a res/color/button_text.xml which looks like this: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:color="#ffff0000"/> <!-- pressed --> <item android:state

Set layout_column and layout_row in GridLayout programmatically

丶灬走出姿态 提交于 2019-11-26 23:22:08
问题 I have a GridLayout (not GridView) where I want to add some views with a special row and column inex. In XML I can set the View with: <TextView android:id="@+id/textView1" android:layout_column="2" android:layout_row="4" android:text="Large Text" /> But how can I set the attributes layout_column and layout_row programmatically? I want something like this: GridLayout grid = new GridLayout(getActivity()); grid.setColumn(2); grid.setRow(4); grid.addView(new Button(getActivity()); 回答1: The

Plural definition is ignored for zero quantity

与世无争的帅哥 提交于 2019-11-26 23:12:16
问题 I use plurals to compile a quantity string for an Android application. I follow exactly what one can find in the tutorials: res.getQuantityString( R.plurals.number_of_comments, commentsCount, commentsCount); Here is the definition of the plurals: <?xml version="1.0" encoding="utf-8"?> <resources> <plurals name="number_of_comments"> <item quantity="zero">No comments</item> <item quantity="one">One comment</item> <item quantity="other">%d comments</item> </plurals> </resources> Interesting