Skip to content

Commit de7a859

Browse files
committed
“拉幕控件占位”
1 parent 27186a3 commit de7a859

File tree

9 files changed

+88
-8
lines changed

9 files changed

+88
-8
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.avenwu.deepinandroid;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
/**
11+
* Created by aven on 12/25/15.
12+
*/
13+
public class CurtainLayoutFragment extends Fragment {
14+
15+
@Nullable
16+
@Override
17+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
18+
return View.inflate(getActivity(), R.layout.curtain_demo, null);
19+
}
20+
}

sample/src/main/java/com/avenwu/deepinandroid/CustomTextViewActivity.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.avenwu.deepinandroid;
22

3+
import android.graphics.drawable.Drawable;
34
import android.os.Bundle;
45
import android.support.v7.app.AppCompatActivity;
6+
import android.text.Html;
7+
import android.widget.TextView;
58

69
/**
710
* Created by chaobin on 11/18/15.
@@ -11,5 +14,17 @@ public class CustomTextViewActivity extends AppCompatActivity {
1114
protected void onCreate(Bundle savedInstanceState) {
1215
super.onCreate(savedInstanceState);
1316
setContentView(R.layout.textview_layout);
17+
18+
((TextView) findViewById(R.id.tv_test)).setText(Html.fromHtml("219473892740218937498127472349823178461982376,40123463218。,74632781964923817649237816498723164982371649782364897231...<img src='icon'>", new Html.ImageGetter() {
19+
@Override
20+
public Drawable getDrawable(String source) {
21+
Drawable mIndicator = getResources().getDrawable(R.drawable.ic_arrow);
22+
if (mIndicator != null) {
23+
mIndicator.setBounds(0, 0, mIndicator.getIntrinsicWidth(), mIndicator.getIntrinsicHeight
24+
());
25+
}
26+
return mIndicator;
27+
}
28+
}, null));
1429
}
1530
}

sample/src/main/res/layout/activity_main.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,19 @@
123123
style="@style/DemoItemStyle"
124124
android:text="字体设置"
125125
android:tag="com.avenwu.deepinandroid.TypefaceActivity"/>
126-
<Button
127-
style="@style/DemoItemStyle"
128-
android:text="Progress"
129-
android:tag="com.avenwu.deepinandroid.CustomProgressActivity"/>
126+
<!--<Button-->
127+
<!--style="@style/DemoItemStyle"-->
128+
<!--android:text="Progress"-->
129+
<!--android:tag="com.avenwu.deepinandroid.CustomProgressActivity"/>-->
130130
<Button
131131
style="@style/DemoItemStyle"
132132
android:text="ExTextView"
133133
android:tag="com.avenwu.deepinandroid.CustomTextViewActivity"/>
134+
<Button
135+
style="@style/DemoItemStyle"
136+
android:text="拉幕弹层"
137+
android:onClick="openFragment"
138+
android:tag="com.avenwu.deepinandroid.CurtainLayoutFragment" />
134139
</LinearLayout>
135140
</ScrollView>
136141

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:background="@android:color/black"
6+
android:orientation="vertical">
7+
<net.avenwu.support.widget.CurtainLayout
8+
android:layout_width="match_parent"
9+
android:layout_height="match_parent"></net.avenwu.support.widget.CurtainLayout>
10+
</LinearLayout>

sample/src/main/res/layout/textview_layout.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@
2929
android:background="@android:color/white"
3030
android:maxLines="2"
3131
android:padding="10dp"
32-
android:text="@string/sample_text"
32+
android:text="@string/sample_text_digt"
3333
android:textColor="@android:color/black"
3434
android:textSize="14sp"
3535
app:expand_collapse_default="true"
3636
app:expand_indicator="@drawable/ic_arrow"/>
37+
38+
<TextView
39+
android:id="@+id/tv_test"
40+
android:padding="10dp"
41+
android:textSize="14sp"
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content" />
3744
</LinearLayout>

sample/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@
2929
<string name="dummy_button">Dummy Button</string>
3030
<string name="dummy_content">DUMMY\nCONTENT</string>
3131
<string name="title_activity_typeface">TypefaceActivity</string>
32+
<string name="sample_text_digt">219473892740218937498127472349823178461982376401234632,1874632781964923817649237816498723164982371649782364897231</string>
33+
<string name="sample_text_eng">ABCDKJBJCSABCJKABSCKJABCKJASBCKJABSCJKASBBBBBBBACBKJVKGVGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHSACASCASCASC</string>
3234
<string name="sample_text">作为中国IT职业在线教育第一品牌 , 极客学院(隶属于北京优亿致远无线技术有限公司)始终致力于“让学习更有效”, 帮助IT从业者高效提升职业技能。极客学院坚持以“最快”的更新速度提供“最新”的课程 , 让IT从业者更有效地学习,让每个人都能通过极客学院享受高质量的职业教育。极客学院推出了中国第一个 FlappyBird、Swift、Apple Watch等相关课程 , 几乎垄断了所有最新的技术和最热的应用课程的首发。</string>
3335
</resources>

support/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apply plugin: 'com.android.library'
2-
apply from: 'custom_mvn_push.gradle'
2+
//apply from: 'custom_mvn_push.gradle'
33

44
android {
55
compileSdkVersion 22
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package net.avenwu.support.widget;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.widget.FrameLayout;
6+
7+
/**
8+
* Created by aven on 12/25/15.
9+
*/
10+
public class CurtainLayout extends FrameLayout {
11+
public CurtainLayout(Context context) {
12+
this(context, null);
13+
}
14+
15+
public CurtainLayout(Context context, AttributeSet attrs) {
16+
super(context, attrs);
17+
}
18+
}

support/src/main/java/net/avenwu/support/widget/ExTextView.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import net.avenwu.support.R;
1616

17+
import java.io.UnsupportedEncodingException;
1718
import java.lang.reflect.Field;
1819

1920
/**
@@ -23,7 +24,7 @@
2324
public class ExTextView extends TextView implements View.OnClickListener, ValueAnimator.AnimatorUpdateListener {
2425

2526
static final String TAG = ExTextView.class.getCanonicalName();
26-
static final String HTML_IMG = "...<img src='http://github.com/icon'/>";
27+
static final String HTML_IMG = "&nbsp;。。。&nbsp;<img src='http://github.com/icon'/>";
2728
int mMaxHeight;
2829
int mCollapsedHeight;
2930
int mMaxLine;
@@ -75,7 +76,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
7576
if (isCollapsed) {
7677
if (mCollapsedText == null) {
7778
int end = getLayout().getLineVisibleEnd(mMaxLine - 1);
78-
CharSequence subString = mFullText.subSequence(0, end - 4);
79+
CharSequence subString = mFullText.subSequence(0, end - 9);
7980
Log.d(TAG, "substring=" + subString + HTML_IMG);
8081
mCollapsedText = Html.fromHtml(subString + HTML_IMG, mImageGetter, null);
8182
}
@@ -120,6 +121,7 @@ public void setText(CharSequence text, BufferType type) {
120121
mFullText = text;
121122
mCollapsedText = null;
122123
isLayout = false;
124+
123125
super.setText(text, type);
124126
}
125127

@@ -170,4 +172,5 @@ public Drawable getDrawable(String source) {
170172
return "icon".equals(source) ? mIndicator : null;
171173
}
172174
};
175+
173176
}

0 commit comments

Comments
 (0)