Skip to content

Commit

Permalink
updated sdk and added RecyclerView sample (available via the menu).
Browse files Browse the repository at this point in the history
  • Loading branch information
AndroidDeveloperLB committed Sep 22, 2016
1 parent 84091f0 commit 7520a06
Show file tree
Hide file tree
Showing 16 changed files with 310 additions and 217 deletions.
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

8 changes: 1 addition & 7 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions AutoFitTextViewSample/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.autofittextviewsample"
android:installLocation="auto"
>
<manifest package="com.example.autofittextviewsample"
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto">

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light" >
android:theme="@style/Theme.AppCompat.Light">
<activity
android:name="com.example.autofittextviewsample.MainActivity"
android:label="@string/app_name" >
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

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

</manifest>
</manifest>
3 changes: 2 additions & 1 deletion AutoFitTextViewSample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile project(':AutoFitTextViewLibrary')
}
61 changes: 32 additions & 29 deletions AutoFitTextViewSample/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<RelativeLayout
android:id="@+id/parametersContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2"
android:orientation="horizontal"
android:padding="4dp" >
android:padding="4dp">

<EditText
android:id="@+id/contentEditText"
Expand All @@ -22,15 +22,15 @@
android:layout_gravity="fill_horizontal"
android:ems="10"
android:hint="content"
android:text="content text sample" />
android:text="content text sample"/>

<Button
android:id="@+id/minusLineCountButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/contentEditText"
android:layout_toRightOf="@+id/textView2"
android:text="-" />
android:text="-"/>

<TextView
android:id="@+id/linesCountTextView"
Expand All @@ -41,53 +41,43 @@
android:layout_toRightOf="@+id/minusLineCountButton"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="2" />
android:text="2"/>

<Button
android:id="@+id/plusLineCountButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/contentEditText"
android:layout_toRightOf="@+id/linesCountTextView"
android:text="+" />
android:text="+"/>

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/minusLineCountButton"
android:layout_alignTop="@+id/widthSeekBar"
android:layout_below="@id/textView2"
android:text="width:"
android:textSize="20dp" />
android:textSize="20dp"/>

<SeekBar
android:id="@+id/widthSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView1"
android:layout_below="@+id/minusLineCountButton"
android:layout_toRightOf="@+id/TextView01"
android:layout_toRightOf="@+id/textView1"
android:max="100"
android:progress="50" />
android:progress="50"/>

<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/heightSeekBar"
android:layout_below="@+id/textView1"
android:text="height:"
android:textSize="20dp" />

<SeekBar
android:id="@+id/heightSeekBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/widthSeekBar"
android:layout_toRightOf="@+id/TextView01"
android:max="100"
android:progress="50" />
android:textSize="20dp"/>

<TextView
android:id="@+id/textView2"
Expand All @@ -97,7 +87,20 @@
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/minusLineCountButton"
android:gravity="center_vertical"
android:text="max lines count:" />
android:text="max lines count:"/>

<SeekBar
android:id="@+id/heightSeekBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/TextView01"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/widthSeekBar"
android:layout_toEndOf="@+id/TextView01"
android:layout_toRightOf="@+id/TextView01"
android:max="100"
android:progress="50"/>
</RelativeLayout>

<FrameLayout
Expand All @@ -106,7 +109,7 @@
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/parametersContainer"
android:background="#ffff0000" >
android:background="#ffff0000">
</FrameLayout>

</RelativeLayout>
</RelativeLayout>
18 changes: 18 additions & 0 deletions AutoFitTextViewSample/res/layout/activity_main2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/activity_main2"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.autofittextviewsample.Main2Activity">

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent" android:id="@android:id/list"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>

</RelativeLayout>
14 changes: 14 additions & 0 deletions AutoFitTextViewSample/res/layout/item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp">

<com.lb.auto_fit_textview.AutoResizeTextView
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="hi"
android:textSize="1000dp"/>
</FrameLayout>
42 changes: 26 additions & 16 deletions AutoFitTextViewSample/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:icon="@android:drawable/ic_menu_info_details"
android:title="@string/more_info" android:showAsAction="always">
<menu>
<group android:menuCategory="container"
android:checkableBehavior="none">
<item android:id="@+id/menuItem_current_repository_website"
android:title="@string/repository_website"></item>
<item android:id="@+id/menuItem_all_my_repositories"
android:title="@string/all_my_repositories"></item>
<item android:id="@+id/menuItem_all_my_apps"
android:title="@string/all_my_apps"></item>
</group>
</menu>
</item>
<item
android:icon="@android:drawable/ic_menu_info_details"
android:title="@string/more_info"
app:showAsAction="always">
<menu>
<group
android:checkableBehavior="none"
android:menuCategory="container">
<item
android:id="@+id/menuItem_show_recyclerViewSample"
android:title="show RecyclerView sample"/>
<item
android:id="@+id/menuItem_current_repository_website"
android:title="@string/repository_website"></item>
<item
android:id="@+id/menuItem_all_my_repositories"
android:title="@string/all_my_repositories"></item>
<item
android:id="@+id/menuItem_all_my_apps"
android:title="@string/all_my_apps"></item>
</group>
</menu>
</item>

</menu>
</menu>
6 changes: 6 additions & 0 deletions AutoFitTextViewSample/res/values-w820dp/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
5 changes: 5 additions & 0 deletions AutoFitTextViewSample/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
2 changes: 1 addition & 1 deletion AutoFitTextViewSample/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
<string name="all_my_apps">All my apps</string>
<string name="more_info">More info</string>
<string name="randomize">Randomize</string>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.example.autofittextviewsample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class Main2Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
RecyclerView recyclerView = (RecyclerView) findViewById(android.R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(new Adapter<ViewHolder>() {
@Override
public ViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
return new ViewHolder(LayoutInflater.from(Main2Activity.this).inflate(R.layout.item, parent, false)) {
};
}

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
StringBuilder sb = new StringBuilder("item:");
for (int i = 0; i <= position; ++i)
sb.append(Integer.toString(position));
holder.textView.setText(sb);
}

@Override
public int getItemCount() {
return 50;
}
});
}

private static class ViewHolder extends RecyclerView.ViewHolder {
final TextView textView;

public ViewHolder(final View itemView) {
super(itemView);
textView = (TextView) itemView.findViewById(android.R.id.text1);
}
}
}
Loading

0 comments on commit 7520a06

Please sign in to comment.