-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Carifio24/ui-improvements
UI improvements
- Loading branch information
Showing
4 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
app/src/main/java/dnd/jon/spellbook/ShortScrollbarRVScrollView.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,47 @@ | ||
package dnd.jon.spellbook; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.widget.ScrollView; | ||
|
||
public class ShortScrollbarRVScrollView extends ScrollView { | ||
public ShortScrollbarRVScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
} | ||
|
||
public ShortScrollbarRVScrollView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
} | ||
|
||
public ShortScrollbarRVScrollView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public ShortScrollbarRVScrollView(Context context) { | ||
super(context); | ||
} | ||
|
||
// This is the value of scrollY when the RV is fully scrolled | ||
private int yScrollRange() { | ||
return super.computeVerticalScrollRange() - getHeight(); | ||
} | ||
|
||
@Override | ||
public int computeVerticalScrollExtent() { | ||
final int yRange = yScrollRange(); | ||
if (yRange <= 0) { | ||
return 0; | ||
} | ||
return super.computeVerticalScrollExtent() / 5; | ||
} | ||
|
||
@Override | ||
public int computeVerticalScrollOffset() { | ||
final int yRange = yScrollRange(); | ||
if (yRange <= 0) { | ||
return 0; | ||
} | ||
return getScrollY() * (getHeight() - computeVerticalScrollExtent()) / yRange; | ||
} | ||
|
||
} |
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