Skip to content
This repository has been archived by the owner on Jun 28, 2020. It is now read-only.

Commit

Permalink
Close #2 and #3 by setting insetForeground to transparent
Browse files Browse the repository at this point in the history
  • Loading branch information
romtsn committed Apr 4, 2017
1 parent 54bc38e commit d403a79
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<activity
android:name="com.rom4ek.sample.arcnavigationview.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<resources>

<style name="AppTheme.NoActionBar">
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
4 changes: 1 addition & 3 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.NoActionBar">
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.design.internal.NavigationMenuView;
import android.support.design.internal.ScrimInsetsFrameLayout;
import android.support.design.widget.NavigationView;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.DrawerLayout;
Expand All @@ -22,6 +24,8 @@
import android.view.ViewOutlineProvider;
import android.widget.TextView;

import java.lang.reflect.Field;

/**
* Created by rom4ek on 10.01.2017.
*/
Expand Down Expand Up @@ -62,9 +66,23 @@ public void init(Context context, AttributeSet attrs) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
setBackgroundColor(Color.TRANSPARENT);
setInsetsColor(Color.TRANSPARENT);
THRESHOLD = Math.round(ArcViewSettings.dpToPx(getContext(), 15)); //some threshold for child views while remeasuring them
}

private void setInsetsColor(int color) {
try {
Field insetForegroundField = ScrimInsetsFrameLayout.class.getDeclaredField("mInsetForeground");
insetForegroundField.setAccessible(true);
ColorDrawable colorDrawable = new ColorDrawable(color);
insetForegroundField.set(this, colorDrawable);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}

@SuppressLint("RtlHardcoded")
private Path createClipPath() {
final Path path = new Path();
Expand Down Expand Up @@ -251,7 +269,7 @@ private Rect locateView(View view) {
protected void dispatchDraw(Canvas canvas) {
canvas.save();

canvas.clipPath(clipPath);
canvas.clipPath(clipPath);;
super.dispatchDraw(canvas);

canvas.restore();
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ ext {
sdk = 25
buildTools = "25.0.2"
minSdk = 14
libraryVersion = "1.0.2"
libraryVersion = "1.0.3"
supportVersion = "25.3.0"
}

0 comments on commit d403a79

Please sign in to comment.