Tag Archives: xml

24,470 views

Create own custom Title Bar TitleBar with a Icon Android example

onCreate in MainActivity.java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);   requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main.xml); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); } You can add to titlebar different Views by xml file. custom_title.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/left_text" android:layout_width="wrap_content" android:layout_height="wrap_content" … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , , | Comments Off on Create own custom Title Bar TitleBar with a Icon Android example
10,746 views

Android button text alignment left right – sample

android:gravity=”left|center_vertical” or android:gravity=”right|center_vertical” <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left|center_vertical" android:paddingLeft="20dp" android:text="My Button" />

Posted in Android Examples Code | Tagged , , | Comments Off on Android button text alignment left right – sample
65,572 views

Turn screen ON OFF Android sample code

WakeLock, PowerManager,uses-permission Android sample. Main.java public class Main extends Activity { private SensorManager mSensorManager; private PowerManager mPowerManager; private WindowManager mWindowManager; private WakeLock mWakeLock; private Button button; private TextView textView;   /** Called when the activity is first created. */ @Override … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on Turn screen ON OFF Android sample code
9,972 views

Android RadioGroup alignment like TableLayout

xml example source code with image. <TableLayout android:layout_width="match_parent" android:id="@+id/idTableInRadioGroup" android:layout_height="wrap_content"> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">     <RadioGroup android:id="@+id/idRadio_group_1_column" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:orientation="vertical"> <RadioButton android:id="@+id/idRadio_1" android:text="@string/textLabel_1"/> <RadioButton android:id="@+id/idRadio_2" android:text="@string/textLabel_2"/> <RadioButton android:id="@+id/idRadio_3" android:text="@string/textLabel_3"/>   </RadioGroup> <RadioGroup android:id="@+id/idRadio_group_2_column" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:orientation="vertical">   … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on Android RadioGroup alignment like TableLayout
5,756 views

Relative layout RelativeLayout Android example

xml RelativeLayout Android example: Eclipse graphical xml layout editor res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/idLabel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Enter word"/> <EditText android:id="@+id/idEntry" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:drawable/editbox_background" android:layout_below="@id/idLabel"/> <Button android:id="@+id/idOk" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/idEntry" android:layout_alignParentRight="true" android:layout_marginLeft="10dip" android:text="OK" /> <Button android:layout_width="wrap_content" … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on Relative layout RelativeLayout Android example
16,651 views

HorizontalScrollView ScrollView horizontal vertical Android xml example

HorizontalScrollView ScrollView LinearLayout horizontal vertical Android xml basic example and image. <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">   // horizontal and vertical Scrollview <ScrollView android:id="@+id/ScrollView01" android:layout_height="135px" android:layout_width="wrap_content" android:scrollbars="horizontal|vertical">   // HorizontalScrollview <HorizontalScrollView android:id="@+id/HorizontalScrollView01" android:layout_height="fill_parent" android:layout_width="wrap_content">   <LinearLayout android:id="@+id/LinearLayout02" … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on HorizontalScrollView ScrollView horizontal vertical Android xml example
20,983 views

Change background color dynamically View TableRow setBackgroundColor Android example

How change background color of View Android sample. MainActivity.java public class MainActivity extends Activity { TextView hTextView; TableRow hTableRow; Button hButton, hButtonStop; private Handler mHandler = new Handler(); private int nCounter = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); … Continue reading

Posted in Android Examples Code | Tagged , , , , , , | Comments Off on Change background color dynamically View TableRow setBackgroundColor Android example
7,401 views

No resource found that matches the given name Eclipse Android xml file

No resource found that matches the given name – error examples. Exist resource file? Is code written correctly? // No resource found that matches the given name (at id with value @id/myButton). android:id="@id/myButton" // invalid id notation android:id="@+id/myButton" // correct … Continue reading

Posted in Android Examples Code, Eclipse | Tagged , , , | Comments Off on No resource found that matches the given name Eclipse Android xml file
4,627 views

No title bar Android application without titlebar style Theme NoTitleBar Android example

Set in AndroidManifest.xml android:theme=”@android:style/Theme.NoTitleBar” AndroidManifest.xml example source code. AndroidManifest.xml   <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myexample.without_titlebar"> <application android:label="My app"> <activity android:name="NoTitleBar" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>

Posted in Android Examples Code | Tagged , , , | Comments Off on No title bar Android application without titlebar style Theme NoTitleBar Android example
33,675 views

Scroll to certain position on application Android example code

ScrollTo(), getTop(), getBottom(), getLeft(), getRight(), ScrollView, LinearLayout Android Java xml example. How get position of a View. MainClass.java /* public void scrollTo (int x, int y) Since: API Level 1 Set the scrolled position of your view. This will cause … Continue reading

Posted in Android Examples Code | Tagged , , , , , , , | Comments Off on Scroll to certain position on application Android example code