哪个app可以买外围;如何系统学习app系统多久会?

github地址:/wangkunlin/AndroidPercentLayout
PercentFrameLayout.java
package android.support.
import android.content.C
import android.content.res.TypedA
import android.util.AttributeS
import android.view.ViewG
import android.widget.FrameL
public class PercentFrameLayout extends FrameLayout {
private final PercentLayoutHelper mH
public PercentFrameLayout(Context context) {
super(context);
mHelper = new PercentLayoutHelper(this);
public PercentFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mHelper = new PercentLayoutHelper(this);
public LayoutParams generateLayoutParams(AttributeSet attrs) {
return new LayoutParams(getContext(), attrs);
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
this.mHelper.adjustChildren(widthMeasureSpec, heightMeasureSpec);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (this.mHelper.handleMeasuredStateTooSmall())
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
super.onLayout(changed, left, top, right, bottom);
this.mHelper.restoreOriginalParams();
public static class LayoutParams extends FrameLayout.LayoutParams implements
PercentLayoutHelper.PercentLayoutParams {
private PercentLayoutHelper.PercentLayoutInfo mPercentLayoutI
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
this.mPercentLayoutInfo = PercentLayoutHelper.getPercentLayoutInfo(
c, attrs);
public LayoutParams(int width, int height) {
super(width, height);
public LayoutParams(ViewGroup.LayoutParams source) {
super(source);
public LayoutParams(MarginLayoutParams source) {
super(source);
public PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo() {
return this.mPercentLayoutI
protected void setBaseAttributes(TypedArray a, int widthAttr,
int heightAttr) {
PercentLayoutHelper.fetchWidthAndHeight(this, a, widthAttr,
heightAttr);
}PercentLinearLayout.java
package android.support.
import android.content.C
import android.content.res.TypedA
import android.support.percent.PercentLayoutH
import android.util.AttributeS
import android.view.ViewG
import android.widget.LinearL
public class PercentLinearLayout extends LinearLayout {
private final PercentLayoutHelper mH
public PercentLinearLayout(Context context) {
super(context);
mHelper = new PercentLayoutHelper(this);
public PercentLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mHelper = new PercentLayoutHelper(this);
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
mHelper.adjustChildren(widthMeasureSpec, heightMeasureSpec);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mHelper.handleMeasuredStateTooSmall()) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
mHelper.restoreOriginalParams();
public LayoutParams generateLayoutParams(AttributeSet attrs) {
return new LayoutParams(getContext(), attrs);
public static class LayoutParams extends LinearLayout.LayoutParams
implements PercentLayoutHelper.PercentLayoutParams {
private PercentLayoutHelper.PercentLayoutInfo mPercentLayoutI
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
mPercentLayoutInfo = PercentLayoutHelper.getPercentLayoutInfo(c,
public LayoutParams(int width, int height) {
super(width, height);
public LayoutParams(ViewGroup.LayoutParams source) {
super(source);
public LayoutParams(MarginLayoutParams source) {
super(source);
public PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo() {
return mPercentLayoutI
protected void setBaseAttributes(TypedArray a, int widthAttr,
int heightAttr) {
PercentLayoutHelper.fetchWidthAndHeight(this, a, widthAttr,
heightAttr);
}PercentRelativeLayout.java
package android.support.
import android.content.C
import android.content.res.TypedA
import android.util.AttributeS
import android.view.ViewG
import android.widget.RelativeL
public class PercentRelativeLayout extends RelativeLayout {
private final PercentLayoutHelper mH
public PercentRelativeLayout(Context context) {
super(context);
mHelper = new PercentLayoutHelper(this);
public PercentRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mHelper = new PercentLayoutHelper(this);
public LayoutParams generateLayoutParams(AttributeSet attrs) {
return new LayoutParams(getContext(), attrs);
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
this.mHelper.adjustChildren(widthMeasureSpec, heightMeasureSpec);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (this.mHelper.handleMeasuredStateTooSmall())
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
super.onLayout(changed, left, top, right, bottom);
this.mHelper.restoreOriginalParams();
public static class LayoutParams extends RelativeLayout.LayoutParams
implements PercentLayoutHelper.PercentLayoutParams {
private PercentLayoutHelper.PercentLayoutInfo mPercentLayoutI
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
this.mPercentLayoutInfo = PercentLayoutHelper.getPercentLayoutInfo(
c, attrs);
public LayoutParams(int width, int height) {
super(width, height);
public LayoutParams(ViewGroup.LayoutParams source) {
super(source);
public LayoutParams(MarginLayoutParams source) {
super(source);
public PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo() {
return this.mPercentLayoutI
protected void setBaseAttributes(TypedArray a, int widthAttr,
int heightAttr) {
PercentLayoutHelper.fetchWidthAndHeight(this, a, widthAttr,
heightAttr);
PercentLayoutHelper.java
package android.support.
import java.util.L
import com.example.pullrefresh.R;
import android.content.C
import android.content.res.TypedA
import android.support.v4.view.MarginLayoutParamsC
import android.support.v4.view.ViewC
import android.util.AttributeS
import android.view.V
import android.view.ViewG
public class PercentLayoutHelper {
private final ViewGroup mH
public PercentLayoutHelper(ViewGroup host) {
this.mHost =
public static void fetchWidthAndHeight(ViewGroup.LayoutParams params,
TypedArray array, int widthAttr, int heightAttr) {
params.width = array.getLayoutDimension(widthAttr, 0);
params.height = array.getLayoutDimension(heightAttr, 0);
public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec) {
int widthHint = View.MeasureSpec.getSize(widthMeasureSpec);
int heightHint = View.MeasureSpec.getSize(heightMeasureSpec);
int i = 0;
for (int N = this.mHost.getChildCount(); i & N; i++) {
View view = this.mHost.getChildAt(i);
ViewGroup.LayoutParams params = view.getLayoutParams();
if ((params instanceof PercentLayoutParams)) {
PercentLayoutInfo info = ((PercentLayoutParams) params)
.getPercentLayoutInfo();
if (info != null)
if ((params instanceof ViewGroup.MarginLayoutParams)) {
info.fillMarginLayoutParams(
(ViewGroup.MarginLayoutParams) params,
widthHint, heightHint);
info.fillLayoutParams(params, widthHint, heightHint);
public static PercentLayoutInfo getPercentLayoutInfo(Context context,
AttributeSet attrs) {
PercentLayoutInfo info =
TypedArray array = context.obtainStyledAttributes(attrs,
R.styleable.PercentLayout_Layout);
float value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_widthPercent, 1, 1,
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.widthPercent =
value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_heightPercent, 1, 1,
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.heightPercent =
value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_marginPercent, 1, 1,
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.leftMarginPercent =
info.topMarginPercent =
info.rightMarginPercent =
info.bottomMarginPercent =
value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_marginLeftPercent, 1,
1, -1.0F);
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.leftMarginPercent =
value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1,
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.topMarginPercent =
value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_marginRightPercent, 1,
1, -1.0F);
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.rightMarginPercent =
value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_marginBottomPercent, 1,
1, -1.0F);
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.bottomMarginPercent =
value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_marginStartPercent, 1,
1, -1.0F);
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.startMarginPercent =
value = array.getFraction(
R.styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1,
if (value != -1.0F) {
info = info != null ? info : new PercentLayoutInfo();
info.endMarginPercent =
array.recycle();
public void restoreOriginalParams() {
int i = 0;
for (int N = this.mHost.getChildCount(); i & N; i++) {
View view = this.mHost.getChildAt(i);
ViewGroup.LayoutParams params = view.getLayoutParams();
if ((params instanceof PercentLayoutParams)) {
PercentLayoutInfo info = ((PercentLayoutParams) params)
.getPercentLayoutInfo();
if (info != null)
if ((params instanceof ViewGroup.MarginLayoutParams))
info.restoreMarginLayoutParams((ViewGroup.MarginLayoutParams) params);
info.restoreLayoutParams(params);
public boolean handleMeasuredStateTooSmall() {
boolean needsSecondMeasure =
int i = 0;
for (int N = this.mHost.getChildCount(); i & N; i++) {
View view = this.mHost.getChildAt(i);
ViewGroup.LayoutParams params = view.getLayoutParams();
if ((params instanceof PercentLayoutParams)) {
PercentLayoutInfo info = ((PercentLayoutParams) params)
.getPercentLayoutInfo();
if (info != null) {
if (shouldHandleMeasuredWidthTooSmall(view, info)) {
needsSecondMeasure =
params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
if (shouldHandleMeasuredHeightTooSmall(view, info)) {
needsSecondMeasure =
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
return needsSecondM
private static boolean shouldHandleMeasuredWidthTooSmall(View view,
PercentLayoutInfo info) {
int state = ViewCompat.getMeasuredWidthAndState(view)
& ViewCompat.MEASURED_STATE_MASK;
return (state == ViewCompat.MEASURED_STATE_TOO_SMALL)
&& (info.widthPercent &= 0.0F)
&& (info.mPreservedParams.width == ViewGroup.LayoutParams.WRAP_CONTENT);
private static boolean shouldHandleMeasuredHeightTooSmall(View view,
PercentLayoutInfo info) {
int state = ViewCompat.getMeasuredHeightAndState(view)
& ViewCompat.MEASURED_STATE_MASK;
return (state == ViewCompat.MEASURED_STATE_TOO_SMALL)
&& (info.heightPercent &= 0.0F)
&& (info.mPreservedParams.height == ViewGroup.LayoutParams.WRAP_CONTENT);
public static abstract interface PercentLayoutParams {
public abstract PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo();
public static class PercentLayoutInfo {
public float widthP
public float heightP
public float leftMarginP
public float topMarginP
public float rightMarginP
public float bottomMarginP
public float startMarginP
public float endMarginP
final ViewGroup.MarginLayoutParams mPreservedP
public PercentLayoutInfo() {
this.widthPercent = -1.0F;
this.heightPercent = -1.0F;
this.leftMarginPercent = -1.0F;
this.topMarginPercent = -1.0F;
this.rightMarginPercent = -1.0F;
this.bottomMarginPercent = -1.0F;
this.startMarginPercent = -1.0F;
this.endMarginPercent = -1.0F;
this.mPreservedParams = new ViewGroup.MarginLayoutParams(0, 0);
public void fillLayoutParams(ViewGroup.LayoutParams params,
int widthHint, int heightHint) {
this.mPreservedParams.width = params.
this.mPreservedParams.height = params.
if (this.widthPercent &= 0.0F) {
params.width = ((int) (widthHint * this.widthPercent));
if (this.heightPercent &= 0.0F) {
params.height = ((int) (heightHint * this.heightPercent));
public void fillMarginLayoutParams(ViewGroup.MarginLayoutParams params,
int widthHint, int heightHint) {
fillLayoutParams(params, widthHint, heightHint);
this.mPreservedParams.leftMargin = params.leftM
this.mPreservedParams.topMargin = params.topM
this.mPreservedParams.rightMargin = params.rightM
this.mPreservedParams.bottomMargin = params.bottomM
MarginLayoutParamsCompat.setMarginStart(this.mPreservedParams,
MarginLayoutParamsCompat.getMarginStart(params));
MarginLayoutParamsCompat.setMarginEnd(this.mPreservedParams,
MarginLayoutParamsCompat.getMarginEnd(params));
if (this.leftMarginPercent &= 0.0F) {
params.leftMargin = ((int) (widthHint * this.leftMarginPercent));
if (this.topMarginPercent &= 0.0F) {
params.topMargin = ((int) (heightHint * this.topMarginPercent));
if (this.rightMarginPercent &= 0.0F) {
params.rightMargin = ((int) (widthHint * this.rightMarginPercent));
if (this.bottomMarginPercent &= 0.0F) {
params.bottomMargin = ((int) (heightHint * this.bottomMarginPercent));
if (this.startMarginPercent &= 0.0F) {
MarginLayoutParamsCompat.setMarginStart(params,
(int) (widthHint * this.startMarginPercent));
if (this.endMarginPercent &= 0.0F) {
MarginLayoutParamsCompat.setMarginEnd(params,
(int) (widthHint * this.endMarginPercent));
public String toString() {
return String
.format(Locale.getDefault(),
&PercentLayoutInformation width: %f height %f, margins (%f, %f,
%f, %f, %f, %f)&,
new Object[] { Float.valueOf(this.widthPercent),
Float.valueOf(this.heightPercent),
Float.valueOf(this.leftMarginPercent),
Float.valueOf(this.topMarginPercent),
Float.valueOf(this.rightMarginPercent),
Float.valueOf(this.bottomMarginPercent),
Float.valueOf(this.startMarginPercent),
Float.valueOf(this.endMarginPercent) });
public void restoreMarginLayoutParams(
ViewGroup.MarginLayoutParams params) {
restoreLayoutParams(params);
params.leftMargin = this.mPreservedParams.leftM
params.topMargin = this.mPreservedParams.topM
params.rightMargin = this.mPreservedParams.rightM
params.bottomMargin = this.mPreservedParams.bottomM
MarginLayoutParamsCompat.setMarginStart(params,
MarginLayoutParamsCompat
.getMarginStart(this.mPreservedParams));
MarginLayoutParamsCompat.setMarginEnd(params,
MarginLayoutParamsCompat
.getMarginEnd(this.mPreservedParams));
public void restoreLayoutParams(ViewGroup.LayoutParams params) {
params.width = this.mPreservedParams.
params.height = this.mPreservedParams.
&?xml version=&1.0& encoding=&utf-8&?&
&resources&
&declare-styleable name=&PercentLayout_Layout&&
&attr name=&layout_widthPercent& format=&fraction& /&
&attr name=&layout_heightPercent& format=&fraction& /&
&attr name=&layout_marginPercent& format=&fraction& /&
&attr name=&layout_marginLeftPercent& format=&fraction& /&
&attr name=&layout_marginTopPercent& format=&fraction& /&
&attr name=&layout_marginRightPercent& format=&fraction& /&
&attr name=&layout_marginBottomPercent& format=&fraction& /&
&attr name=&layout_marginStartPercent& format=&fraction& /&
&attr name=&layout_marginEndPercent& format=&fraction& /&
&/declare-styleable&
&/resources&
调用案例:需要注意的是要用res-auto声名一个命名空间xmlns:app=&/apk/res-auto&
&LinearLayout xmlns:android=&/apk/res/android&
xmlns:tools=&/tools&
xmlns:app=&/apk/res-auto&
android:layout_width=&match_parent&
android:layout_height=&match_parent&
android:orientation=&vertical&&
&android.support.percent.PercentLinearLayout
android:layout_width=&match_parent&
android:layout_height=&match_parent&
android:background=&#ff0000&&
android:layout_width=&0dp&
android:layout_height=&wrap_content&
android:text=&testtesttesttesttest&
android:background=&#ffffff&
app:layout_widthPercent=&30%&/&
&/android.support.percent.PercentLinearLayout&
&/LinearLayout&
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:90683次
积分:1990
积分:1990
排名:第16584名
原创:41篇
转载:436篇
(11)(5)(21)(17)(18)(19)(13)(17)(9)(1)(12)(26)(23)(12)(13)(31)(17)(20)(29)(68)(41)(25)(6)(10)(4)(2)(14)(1)android百分比布局Eclipse版
Android平台开发
开发语言:Java
实例大小:1.46M
下载次数:
浏览次数:
发布时间:
实例类别:Android平台开发
发 布 人:
所需积分:2
&相关标签:
同类人气实例
实例下载地址
android百分比布局Eclipse版
不能下载?内容有错? 点击这里报错
好例子网口号:伸出你的我的手 & 分享!
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
Copyright &
好例子网(www.haolizi.net).All Rights Reserved备案编号:冀ICP备号 石公备号(10)I have a set of data in the following format:
Resp | Q1 | Q2
I'd like to show the count and % of people who gave an answer greater than 3. So in this case, the output would be:
Question | Count
Any suggestions?
解决方案 Although it sounds like a fairly easy thing, it is a bit more complicated.
Firstly your data is not row based so you will have to pivot it.
Load your data into Tableau
In the DataSource Screen choose column Q1 and Q1, right click on them and chosse "Pivot"
Name the column with the answers "Answers" (just for clarity.
You should get a table that looks like this:
Now you need to create a calculated field (I called it Overthreshold to check for your condition:
if [Answer] & 3 then
At this point you could substitute the 3 with a parameter in case you want to easily change that condition.
You can already drop the pills as follows to get the count:
Now if you want the percentage it gets a bit more complicated, since you have to determine the count of the questions and the count of the answers > 3 which is information that is stored in two different columns.
Create another Calculated field with this calculation COUNT([Overthreshold]) / AVG({fixed [Question]:count([Answer])})
drop the created pill onto the "text" field or into the columns drawer and see the percentage values
right click on the field and choose Default Propertiess / Number Format to have it as percentage rather than a float
To explain what the formular does:
It takes the count of the answers that are over the threshold and devides it by the count of answers for each question. This is done by the fixed part of the formular which counts the rows that have the same value in the Question column. The AVG is only there because Tableau needs an aggregeation there. Since the value will be the same for every record of the question, you could also use MIN or MAX.
It feels like there should be an eassier solution but right now I cannot think of one.
本文地址: &
我有一组数据,格式如下:
P1 | 4 | 5
P2 | 1 | 2
P3 | 4 | 3
P4 | 6 | 4
我想显示回答大于3的人数和百分比。所以在这种情况下,输出将是:
计数|百分比 Q1 | 3 | 75% Q2 | 2 | 50%
有任何建议吗?
解决方案 虽然听起来像一个相当容易的事情,它是一个更复杂。
将数据加载到Tableau中
在DataSource屏幕中,选择列Q1和Q1,右键单击它们并选择“Pivot”
将答案命名为“Answers” 。您应该得到一个如下所示的表:
现在您需要创建一个计算字段(我称之为 Overthreshold ,以检查您的条件:
if [Answer]& 3 then
此时,您可以用参数替换 3 改变那个条件你可以按如下方式取药:
现在如果你想要的百分比,它得到一个更复杂,因为你必须确定问题的数量和答案的数量> 3,这是存储在两个不同的列的信息。
使用此计算创建另一个计算字段 COUNT([Overthreshold])/ AVG({fixed [Question]:count })
将创建的药片放在“文本”字段或列抽屉中,并查看百分比值
右键点击字段,然后选择默认属性/数字格式将其设置为百分比而不是浮点型
要解释什么是公式:它需要超过阈值的答案计数,每个问题的答案数。这是通过 fixed 部分计算 Question 列中具有相同值的行来完成的。
AVG 只在那里,因为Tableau需要在那里聚集。由于对于问题的每个记录的值都是相同的,因此也可以使用 MIN 或 MAX
感觉应该有一个更简单的解决方案,但现在我不能想到一个。
本文地址: &
扫一扫关注官方微信Oracle(13)
需求:在分组统计的时候,显示每个分组所占的百分比
实现代码:
COUNT(1) rs ,100*round(COUNT(*)/SUM(COUNT(*)) OVER(),4)||'%'
总结:count和order by 大家都非常熟悉了,主要是sum时使用over函数。
over函数使用参考:
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1780372次
积分:21797
积分:21797
排名:第267名
原创:433篇
转载:241篇
评论:408条
(2)(1)(3)(9)(1)(2)(4)(5)(1)(5)(4)(5)(1)(8)(1)(6)(1)(2)(3)(1)(3)(3)(1)(3)(3)(1)(1)(6)(7)(4)(5)(7)(9)(4)(2)(10)(10)(15)(5)(7)(4)(14)(10)(5)(1)(2)(3)(2)(2)(1)(1)(10)(9)(1)(9)(7)(2)(28)(1)(18)(13)(4)(11)(10)(5)(2)(9)(2)(5)(7)(6)(5)(19)(39)(40)(43)(35)(21)(10)(19)(5)(15)(34)(17)

我要回帖

更多关于 学习app系统 的文章

 

随机推荐