Placing text over an image - Android UI
If you are trying to align some text over an image and finding it difficult with
RelativeLayout and any other ways, just do this. Use a
You can change the location of text over image by just changing
android:gravity attribute of the
The below code which I found in stackoverflow.com places some text over center of an image.
PS: This only works inside
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativelayout" android:layout_width="match_parent" android:layout_height="
match_parent” > <ImageView android:id=”@+id/imageView” android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/imageSouce" /> <TextView android:id=”@+id/imageViewText” android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft=”@+id/myImageView” android:layout_alignTop=”@+id/myImageView” android:layout_alignRight=”@+id/myImageView” android:layout_alignBottom=”@+id/myImageView” android:layout_margin="1dp" android:gravity="center" android:text="Hello" android:textColor="#000000" /> </RelativeLayout>
Backup and restore your unrooted android device using ADB
If you want to backup your android device to a PC, but do not want to root it, here is a simple solution for that.
"No need to have super user privilege to carry out backup and restore operation "
First attach your device to computer. Select MTP as transfer protocol.
Enable USB debugging on your device by going to Settings -> Developer options.
You need to have Android SDK installed in your director, so that you can use adb to backup all your data to your computer had disk.
Open Terminal in your computer and run
$ adb backup -all -apk -shared <backup-file-name>.ab
Your device will ask you to enter a password, please do it.
This will backup all your phone data, including app data and data stored in SD card into a file called <backup-file-name>.ab
You can run adb from anywhere if directory where it is located is added to path variables. Otherwise you have to navigate into that directory and run adb from there.
Similarly, to restore the backup data to your device, follow the following steps.
Attach your device to computer and run $ adb devices from computer terminal to check whether device is online or not.
If all goes well, move to directory where <backup-file-name>.ab is located and run
$ adb restore <backup-file-name>.ab
If you want to backup your device to cloud, you can use an app called Helium which is developed by ClockworkMod developers.
Watch this TV ad. One of the coolest ever !
Using ‘git remote’ to add a remote origin manually
Before reading this post please understand what 'local' and 'remote' repositories in git means. This is very important to understand difference between local and remote git repositories.
In simple words,
local git repository is a directory which exists in your computer.
remote git repository is the directory which exists in your github account ( or say bitbucket ).
Suppose say you have some day-to-day-use shell scripts in your computer ( say in $HOME/.scripts/ directory ) and you want to store them into a new repository ( this remote repository doesn’t exist yet ) in your Github account.
Note: You are not cloning a remote git repository into your machine here at all. You are just pushing your already existing local scripts into a newly created remote git repository using ‘git remote’.
Do the following things
- Go to your github page and create a new repository called ‘scripts’
- Now go to your local directory which contains the scripts ( which is in your machine ) and initiate a new empty local git repository using this command
- Now add the file contents to index using
git add *
- Commit the changes
git commit -m “adding scripts”
- Since this local_repository/scripts_directory is not a clone of any remote git repository yet, no remote origin exists for this local directory. You have to add the manually created ‘scripts’ directory as remote origin ( See first bullet )
git remote add origin https://github.com/<github-username>/scripts.git
- Last step is to push the local scripts to remote repository
git push -u origin master
Now go to https://github.com/<github-username>/scripts