布局:
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title_template"
android:layout_width="match_parent"
android:text="hahahah"
android:layout_height="700dp" />
<com.tky.mpchart.View.BarChart2View
android:id="@+id/fl_chart2"
android:layout_below="@+id/title_template"
android:layout_width="match_parent"
android:layout_height="600dp" />
</RelativeLayout>
</ScrollView>
自定义控件:
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
this.setMeasuredDimension(this.measureWidth(widthMeasureSpec), this.measureHeight(heightMeasureSpec));
}
private int measureWidth(int measureSpec) {
int result = 100;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
if(specMode == 1073741824) {
result = specSize;
} else if(specMode == -2147483648) {
result = Math.min(result, specSize);
}
return result;
}
private int measureHeight(int measureSpec) {
int result = 100;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
if(specMode == 1073741824) {
result = specSize;
} else if(specMode == -2147483648) {
result = Math.min(result, specSize);
}
return result;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。