Skip to content

Commit

Permalink
sample of BitmapDrawable with tileMode
Browse files Browse the repository at this point in the history
  • Loading branch information
commonsguy committed Mar 19, 2013
1 parent bc021f4 commit b45a3ce
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Drawable/TileMode/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions Drawable/TileMode/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TileModeSampler</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
24 changes: 24 additions & 0 deletions Drawable/TileMode/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.commonsware.android.tilemode"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15"/>

<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar">
<activity android:name="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
20 changes: 20 additions & 0 deletions Drawable/TileMode/proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
15 changes: 15 additions & 0 deletions Drawable/TileMode/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-16
android.library.reference.1=../../external/ActionBarSherlock
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Drawable/TileMode/res/drawable-xhdpi/hatch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Drawable/TileMode/res/drawable/_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/hatch"/>
3 changes: 3 additions & 0 deletions Drawable/TileMode/res/drawable/clamp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/hatch"
android:tileMode="clamp"/>
3 changes: 3 additions & 0 deletions Drawable/TileMode/res/drawable/mirror.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/hatch"
android:tileMode="mirror"/>
3 changes: 3 additions & 0 deletions Drawable/TileMode/res/drawable/repeat.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/hatch"
android:tileMode="repeat"/>
8 changes: 8 additions & 0 deletions Drawable/TileMode/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/widget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

</LinearLayout>
9 changes: 9 additions & 0 deletions Drawable/TileMode/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<resources>

<string name="app_name">tileMode Sampler</string>
<string name="clamp">Clamp</string>
<string name="repeat">Repeat</string>
<string name="mirror">Mirror</string>
<string name="_default">Default</string>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/***
Copyright (c) 2012 CommonsWare, LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.
From _The Busy Coder's Guide to Android Development_
http://commonsware.com/Android
*/

package com.commonsware.android.tilemode;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.ActionBar.TabListener;
import com.actionbarsherlock.app.SherlockActivity;

public class MainActivity extends SherlockActivity implements
TabListener {
private static final int TABS[]= { R.string._default, R.string.clamp,
R.string.repeat, R.string.mirror };
private static final int DRAWABLES[]= { R.drawable._default,
R.drawable.clamp, R.drawable.repeat, R.drawable.mirror };
private View widget=null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

widget=findViewById(R.id.widget);

ActionBar bar=getSupportActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

for (int i=0; i < TABS.length; i++) {
bar.addTab(bar.newTab().setText(getString(TABS[i]))
.setTabListener(this));
}
}

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
widget.setBackgroundResource(DRAWABLES[tab.getPosition()]);
}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// no-op
}

@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// no-op
}
}

0 comments on commit b45a3ce

Please sign in to comment.