-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
172 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
android:scrollbars="none"> | ||
|
||
<com.ms.banner.Banner | ||
android:id="@+id/banner1" | ||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="150dp" | ||
android:layout_marginTop="50dp" | ||
app:pageMargin="20dp" /> | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<com.ms.banner.Banner | ||
android:id="@+id/banner2" | ||
android:layout_width="match_parent" | ||
android:layout_height="180dp" | ||
android:layout_marginTop="30dp" /> | ||
<com.ms.banner.Banner | ||
android:id="@+id/banner1" | ||
android:layout_width="match_parent" | ||
android:layout_height="150dp" | ||
app:pageMargin="20dp" /> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/banner" | ||
android:layout_marginTop="20dp" | ||
android:padding="10dp" | ||
android:text="这是一个修改banner布局文件的例子,你可以按照这个套路修改里面的内容" /> | ||
<com.ms.banner.Banner | ||
android:id="@+id/banner2" | ||
android:layout_width="match_parent" | ||
android:layout_height="150dp" /> | ||
|
||
<com.ms.banner.Banner | ||
android:id="@+id/banner3" | ||
android:layout_width="match_parent" | ||
android:layout_height="150dp" | ||
app:arc_background="@android:color/darker_gray" | ||
app:arc_height="10dp" | ||
app:indicator_margin="13dp" /> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@android:color/darker_gray" | ||
android:padding="10dp" | ||
android:text="这是一个修改banner布局文件的例子,你可以按照这个套路修改里面的内容" /> | ||
|
||
</LinearLayout> | ||
</LinearLayout> | ||
</ScrollView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
rollbanner/src/main/java/com/ms/banner/view/ArcShapeView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.ms.banner.view; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Paint; | ||
import android.graphics.Path; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
public class ArcShapeView extends View { | ||
|
||
private Paint mPaint; | ||
private Path mPath; | ||
private int arcHeight = 0; | ||
private int background = 0XFFFFFFFF; | ||
private int direction = 0; | ||
|
||
public ArcShapeView(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public ArcShapeView(Context context, AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public ArcShapeView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
|
||
mPaint = new Paint(); | ||
mPaint.setAntiAlias(true); | ||
mPaint.setStyle(Paint.Style.FILL); | ||
mPath = new Path(); | ||
} | ||
|
||
@Override | ||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
setMeasuredDimension(widthMeasureSpec, heightMeasureSpec); | ||
super.onMeasure(widthMeasureSpec, heightMeasureSpec); | ||
} | ||
|
||
@Override | ||
protected void onDraw(Canvas canvas) { | ||
super.onDraw(canvas); | ||
|
||
mPaint.setColor(background); | ||
|
||
if (direction == 0) { | ||
mPath.moveTo(0, getHeight()); | ||
mPath.quadTo(getWidth() / 2, getHeight() - 2 * arcHeight, getWidth(), getHeight()); | ||
canvas.drawPath(mPath, mPaint); | ||
} else { | ||
mPath.moveTo(0, getHeight()); | ||
mPath.lineTo(0, getHeight() - arcHeight); | ||
mPath.quadTo(getWidth() / 2, getHeight(), getWidth(), getHeight() - arcHeight); | ||
mPath.lineTo(getWidth(), getHeight()); | ||
canvas.drawPath(mPath, mPaint); | ||
} | ||
} | ||
|
||
public void setArcHeight(int arcHeight) { | ||
this.arcHeight = arcHeight; | ||
} | ||
|
||
public void setBackground(int background) { | ||
this.background = background; | ||
} | ||
|
||
public void setDirection(int direction) { | ||
this.direction = direction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters