Uygulamamda kullanmam gereken bir özel Viewgroup
yaptım, ancak bir ScrollView
içine koymam gerekiyor. Düzen yalnızca benim özel ViewGroup
ile yapıldığında her şey iyi çalışıyor, ancak bir ScrollView
içine koyduğumda hiçbir şey göremiyorum. Benim düzen:ScrollView, özel bir düzen görünmez yapar
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.example.test.CustomLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</com.example.test.CustomLayout>
</ScrollView>
Benim viewgroup:
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
/* do something and call for each child
View v = getChildAt(i);
v.measure(wspec, hspec);
*/
setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec));
}
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
//do something and call layout on every child
}
GÜNCELLEME: My CustomLayout sınıfı 2
public class CustomLayout extends ViewGroup{
/*My params*/
public CustomLayout(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public CustomLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
//do something and call layout on every child
}
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
/* do something and call for each child
View v = getChildAt(i);
v.measure(wspec, hspec);
*/
setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec));
}
}
GÜNCELLEME: Üzgünüm ama başka denemeden yapılmış ve eğer benziyor ViewMotureSpec = 0'a sahip olduğum onMeasure yönteminde bir viewview görünümüne sahibim, sonra viewgroup'u başka bir düzende yerleştirirsem, bir tamsayı var. Belki bu yardımcı olur? Ayrıca sağ aşağıya bu contructor kullandığınız layout_height
, hiçbir sonuç gibi kod aşağıda ekleyin. – DLock